i new use angularjs. have create directives , service within seprate files. when including service directive there error: [$injector:modulerr].
here file structure , files :-
directive :- video_course.js
videocourseapp.directive('mcssform' ,function(){ return{ restrict : 'c', templateurl : 'assets/template_blocks/mcss_form.html', link: function(scope,element,attribute){ } }; }); videocourseapp.directive('addnewmsccoption', function(incrementid){ return{ replace: true, restrict : 'c', template : '<li><input name="test" type="radio" ng-model="videocoursequestions.mcss_option"/><input ng-model="videocourseoptions.option{{newid}}" type="text" class="option" placeholder = "enter option{{newid}}" />', link: function(scope,element,attribute){ scope.newid = incrementid.getandincrement; } }; });
and here service file :- videoservice.js
videocourseapp.service('incrementid', function(){ var index = 4; this.getandincrement = function () { return index++; }; });
and @ here main app.js file methods defined :-
var videocourseapp = angular.module('videocourse' , ['ngdragdrop','mcssform','addnewmsccoption']); videocourseapp.controller('video_course_add_question',function($scope, $timeout, $compile){ });
here index.html file:->
<script src="assets/js/video_course/app.js"></script> <script src="assets/js/directives/video_course.js"></script> <script src="assets/js/services/video_services.js"></script>
this give error of injector module. problem , how can manage these dependencies in proper way.
your problem wity way define module. adding directives dependencies module videocourseapp when these directives in same module. modules defined module word can injected dependencies module. try remove these directives module defension.
hope helps.
Comments
Post a Comment