So, using angularJS, I want to separate my directives in their own files for more clarity. I tried some suggestions I found here and elsewhere but it didn't work.
For now my directive is in the controller file which is also the file where I define my module.
Controller.js :
var app = angular.module("viewerApp", ["ngDialog"]);
app.config(['ngDialogProvider', function (ngDialogProvider) {
ngDialogProvider.setDefaults({
className: 'ngdialog-theme-default',
plain: false,
showClose: true,
closeByDocument: true,
closeByEscape: true,
appendTo: false,
preCloseCallback: function () {
console.log('default pre-close callback');
}
});
}]);
app.controller('viewerController', function ($scope, $rootScope, ngDialog) {
/*
Here I have most of my $scope manipulations and functions
*/
});
app.controller('InsideCtrl', function ($scope, ngDialog) {
/*
Small controller to handle some dialog event
*/
});
app.directive('myDirective', function() {
return {
template: 'Directive, lang: {{ currentLanguage }}'
};
})
Then in my HTML file :
<body ng-keypress="handleKeys($event)" ng-controller="viewerController">
{{ "Default : " + defaultLanguage + " - Current : " + currentLanguage }}<br />
<my-directive></my-directive>
So this way it is working fine, I got my test template displayed just like I want.
But when I move the code corresponding to the directive to a new file, it stops working.
FYI I tried the following in the new file :
app.directive('myDirective', function() {
return {
template: 'Directive, lang: {{ currentLanguage }}'
}
});
/* ----------------- */
angular.module("viewerApp", ["ngDialog"]).directive('myDirective', function() {
return {
template: 'Directive, lang: {{ currentLanguage }}'
};
})
/* ----------------- */
angular.module("viewerApp").directive('myDirective', function() {
return {
template: 'Directive, lang: {{ currentLanguage }}'
};
})
How can I fix this ?
Regards.