Issue
I'm using Angularjs in my project and wonder if I can add multiple multiple factories and directives to one angular module like this: (after added like this, only the first directive and factory is working and show results on browser, the second not)
app.js:
var app = angular.module("quizApp", []);
app.directive("quiz", function (quizFactory) {
//...
});
app.factory("quizFactory", function () {
//...
});
app.directive("quiz2", function (quizFactory2) {
//...
});
app.factory("quizFactory2", function () {
//...
});
Solution
The problem is not the 2nd directive + factory are not registered correctly. The problem is all about self-closing tag doesn't work correctly with custom directive as you write <quiz />.
There was a thread talking about that earlier https://github.com/angular/angular.js/issues/1953. To sum up, you have to write as following to make it work:
<quiz></quiz>
<quiz2></quiz2>
Answered By - tmhao2005
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.