Hi,
I'm new to AngularJS and i wanna do injection in a Directive .
can u guys tell me why there is the problem with my tab dependency
in the directive i tried to inject the tab factory
but the alert tell me that my tab object is undefined .... and the google
chrome console tell me that tab doesnt know any of his method....because
he's undefined
there is the code thx
var myApp = angular.module('monSiteWeb', []);
myApp.factory('tab', function () {
var tabPosition = 1;
this.setTab = function (tabPos) {
tabPosition = tabPos;
};
this.getTab = function () {
return tabPosition;
};
this.isTabSelected = function (tabPos) {
if (tabPosition === tabPos) {
return true;
}
return false;
};
});
myApp.directive('navigationBar', ['tab', function (tab) {
alert(tab);
return {
restrict: 'E',
templateUrl: '../Template/navigation-bar.html',
controller: function () {
this.changeTab = function (tabPos) {
tab.setTab(tabPos);
};
this.isTabSelected = function (tabPos) {
if (tab.isTabSelected(tabPos)) {
return true;
}
return false;
};
},
controllerAs: "navigation"
}
}]);.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.