-
Notifications
You must be signed in to change notification settings - Fork 510
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
ocLazyLoad loads my directives twice #58
Comments
Hi, any chance to see the code ? It's hard to know what the problem is without it. |
........ directive (function (module) {
module.directive("uiInputText", ["$q", "$http", function ($q, $http) {
return {
restrict: "E",
replace: true,
transclude: false,
templateUrl:'/app/templates/formInput.html' ,
scope: {
type: "@",
label: "@",
placeholder: "@",
id: "@",
validation: "@",
state: "@",
feedback: "@",
value: "@",
orientation: "@",
labelSize: "@",
model: '=',
descriptor: '&?',
disabled: "@"
}
}
}]);
})(angular.module('application')); ............... loading in $routeProvider $ocLazyLoad.load({
name:'application',
files:files,
}).then(function(){
defer.resolve();
}); comment: files are contain services and controllers path ........ and config of provider $ocLazyLoadProvider.config({
events: true,
debug: true,
cache:true
}); |
Could you post the complete $routeProvider config please ? |
(function (module) {
module.config(['$locationProvider', '$routeProvider', 'translationProvider', '$provide', '$controllerProvider', function ($locationProvider, $routeProvider, translationProvider, $provide, $controllerProvider) {
$routeProvider
.when('/', {
redirectTo: '/home',
resolve: {
load: function ($http, $q, propertyFileReader,$ocLazyLoad) {
return loadModules($http, $q, propertyFileReader,$ocLazyLoad);
}
}
})
.when('/:page*', {
templateUrl: function (parameters) {
var page = parameters.page;
if (!/\.html$/.test(page)) {
page = page + ".html";
}
return "/app/view/" + page;
},
resolve: {
load: function ($http, $q, propertyFileReader,$ocLazyLoad) {
return loadModules($http, $q, propertyFileReader,$ocLazyLoad);
}
}
});
function loadModules($http, $q, propertyFileReader,$ocLazyLoad) {
var defer = $q.defer();
if (!$http.loaded) {
$http.get('/app/resources/controllers.properties').then(function (result) {
var properties = propertyFileReader(result.data);
var files=[];
angular.forEach(properties ,function(value,key){
files.push(key);
});
$ocLazyLoad.load({
name:'application',
files:files
}).then(function(){
defer.resolve();
});
});
} else {
defer.resolve();
}
return defer.promise;
}
}]);
})(angular.module('application')); |
Hmm I don't really see any problem with your code. What is in the template "/app/templates/formInput.html" ? |
Or do you see the directive file being loaded twice in the network tab of your code inspector ? |
When I remove the ocLazyLoad from my project, everything seems good. this is the template and only that directive use it <div ng-class="{'form': orientation != 'inline','form-horizontal': orientation == 'horizontal', 'form-inline form-inline-container': orientation == 'inline'}">
<div class="form-group"
ng-class="{'has-feedback': feedback, 'has-success': state == 'valid', 'has-error': state == 'invalid', 'has-warning': state == 'warning', 'has-info': state == 'notice'}">
<label for="{{id}}" ng-class="{'sr-only': orientation == 'inline'}"
class="control-label {{(orientation == 'horizontal') ? ('col-sm-' + labelSize) : ''}}"><span
ng-if="label">{{label}}</span><span
ng-if="!label && orientation == 'vertical'"> </span></label>
<div ng-show="orientation != 'inline'"
class="{{(orientation == 'horizontal') ? ('col-sm-' + (12 - labelSize)) : ''}}">
<input id="{{id}}" ng-disabled="disabled" class="form-control" type="{{type}}"
placeholder="{{placeholder}}" ng-model="model"/>
<span ng-if="feedback" class="glyphicon glyphicon-{{feedback}} form-control-feedback"></span>
</div>
<input ng-disabled="disabled" ng-show="orientation == 'inline'" id="{{id}}" class="form-control"
type="{{type}}" placeholder="{{placeholder}}" ng-model="model"/><span
ng-if="orientation == 'inline' && feedback"
class="glyphicon glyphicon-{{feedback}} form-control-feedback"></span>
</div>
</div> |
do you see the directive file being loaded twice in the network tab of your code inspector ? |
yes, when I debug the project, directives load twice |
and I don't load directives using $ocLazyLoad |
In the console with debug:true you should see the components loaded with ocLazyLoad, is your directive listed ? It shouldn't since you don't lazy load it. If it does, could you post the complete log please ? Could you also try the version 0.3.3 of ocLazyLoad and see if you have the same problem please ? https://github.com/ocombe/ocLazyLoad/releases/tag/0.3.3 |
ocLazyLoad.fileLoaded app/js/directives/uiInputText.js angular.js:10028 and also I have the problem |
The problem is Multiple directives [uiInputText, uiInputText] asking for template on: < div ................ > |
I have solved the problem by removing referring to the directives in the index.html, but I cant remove ng-grid dependency from the index.html. because I need ngGrid dependency in the defining of the application. And the weird thing is all grids rendered twice. I mean in the screen I see tuple of grids |
I've added |
Glad to hear that, is it ok to close the issue then ? |
I'm having the same issue and I don't really understand what you did to fix this. I've added ocLazyLoad. It seems to be working except when I select a button that used to raise a modal dialog I get this error. If I remove ocLazyLoad then the popup dialog works again. Error: [$compile:multidir] Multiple directives [modalBackdrop, modalBackdrop] asking for template on: <div class="modal-ba |
@robertdunaway - see my tweak in #77. I was having the same issue and that fixed it for me. |
Fixed in 0.3.9 ! |
Hi dear ocombe.
thanks a lot for your framework.
I have a problem with your framework when I then js files is loading in $routeProvider.
I have added my js files directives into index.html. and load the services and controllers using your framework. directives and controllers and services are defined in 'application' module. when I load js files using $ocLazyLoad, your framework runs the directive twice and I see this error:
Multiple directives [uiInputText, uiInputText] asking for template on: ......
The text was updated successfully, but these errors were encountered: