-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v1.0.8 two instance of same directives(or controller) in one scene #86
Comments
It's a Suggestion as: |
I have try to fix this line 459
+ $css.stylesheetRefrences = {};
/**
* Bind: binds css in scope with own scope create/destroy events
**/
$css.bind = function (css, $scope) {
if (!css || !$scope) {
if(DEBUG) $log.error('No scope or stylesheets provided');
return;
}
var result = [];
// Adds route css rules to array
if (angular.isArray(css)) {
angular.forEach(css, function (cssItem) {
result.push(parse(cssItem));
});
} else {
result.push(parse(css));
}
+ angular.forEach(result, function(stylesheet){
+ var href = stylesheet.href;
+ if(!$css.stylesheetRefrences[href]) { $css.stylesheetRefrences[href] = [];}
+ var arr = $css.stylesheetRefrences[href];
+ if(arr.indexOf($scope) < 0) {
+ arr.push($scope);
+ }
+ });
$css.add(result);
if(DEBUG) $log.debug('$css.bind(): Added', result);
$scope.$on('$destroy', function () {
- $css.remove(result);
- if(DEBUG) $log.debug('$css.bind(): Removed', result);
+ var stylesheets = [];
+ angular.forEach(result, function(stylesheet){
+ var arr = $css.stylesheetRefrences[stylesheet.href], idx = -1;
+ if(arr && (idx = arr.indexOf($scope)) >= 0) {
+ arr.splice(idx, 1);
+ }
+ if(arr.length <= 0) {
+ stylesheets.push(stylesheet);
+ }
+ });
+ if(stylesheets.length > 0) {
+ $css.remove(result);
+ if(DEBUG) $log.debug('$css.bind(): Removed', result);
+ }
});
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had add two directives to one view same time. like this:
I used $css.bind(....., $scope) in controller of directive
when i try to close DIV2 by set model2 === false
DIV1'css style dispeared unexpectly!!! why ????
The text was updated successfully, but these errors were encountered: