angular bootstrap - AngularJS Error: [$injector:unpr] Unknown provider: -


i getting unknown provider error when attempting launch angular bootstrap modal window app clicking on image. launch same type of modal elsewhere in app.

here screenshot of error in debugger

is there wrong controller code below? looked @ several other unknown provider error posts on stack, , knowledge i'm doing things properly.

app.controller('modalinstancectrl', function($scope, $modalinstance, items,  removevideofromcart, removeliteraturefromcart, producthasitems, cartitemhasvideos,  cartitemhasliterature, getcartmailtobody, cartmailtolink, logsentitems) {      $scope.items = items;      $scope.ok = function() {         $modalinstance.close($scope.test);     };      $scope.removevideofromcart = function (video, familyindex, index) {         removevideofromcart(video, familyindex, index);         $scope.cartmailtolink = getcartmailtobody(); //update mailto link body remove video links     }      $scope.removeliteraturefromcart = function (literature, familyindex, index) {         removeliteraturefromcart(literature, familyindex, index);          $scope.cartmailtolink = getcartmailtobody(); //update mailto link body remove lit links     }             $scope.cancel = function() {         $modalinstance.dismiss('cancel');     };      $scope.producthasitems = function(index) {         return producthasitems(index);     }      $scope.cartitemhasvideos = function(index) {         return cartitemhasvideos(index);     }      $scope.cartitemhasliterature = function (index) {         return cartitemhasliterature(index);     }      $scope.getcartmailtobody = function () {         getcartmailtobody();     }     $scope.cartmailtolink = getcartmailtobody();      $scope.logsentitems = function () {         logsentitems();     }  }); 

thank time. let me know if need more information or if being unclear.

i'm going assume app points declaration of module defined @ root of app e.g. in app.js:

app = angular.module('app', []); 

and you're including each dependency within index.html e.g. after angular scripts , app.js

<script src="yourdependency.js"></script> 

in terms of controller code itself, don't need assign $scope property contains function calls removevideofromcart service within 'modalinstancectrl' controller, because still need call wrapper function again (which looks not doing).

you can call method within controller rather wrap in function e.g.

$scope.removevideofromcart = removevideofromcart(video, familyindex, index); 

or call service e.g. if don't need bind data ui sending form data on success redirects elsewhere (although in case looks want bind data ui):

removevideofromcart(video, familyindex, index); 

it's not clear code parameters each service originate from. within items object? e.g.

var video, familyindex, index vm.items = items;     video = items.video;    familyindex = items.familyindex;    index = items.index; 

in terms of style, prefer not assigning module instances variable , instead use setter syntax (following [john papa's] (https://github.com/johnpapa/angular-styleguide#modules) styleguide, included in todd motto's), so:

angular     .module('app')     .controller('modalinstancectrl', modalinstancectrl);  modalinstancectrl.$inject['your', 'dependencies', 'go', 'here']  function modalinstancectrl(/*dependencies here parameters e.g.*/, removevideofromcart) {      var vm = this; // use in place of $scope , clarifies context of keyword     vm.items = items;      video = items.video;     familyindex = items.familyindex;     index = items.index;      $scope.removevideofromcart = removevideofromcart(video, familyindex, index);     $scope.removeliteraturefromcart = removeliteraturefromcart(literature, familyindex, index);     //etc  }); 

nb: prefer facade of methods e.g. clearcartandclosemodal('other', 'services') hide of implementation details controller. makes easier create 1 controller per view in turn easier test beacuse have pushed logic services. i'm not clear code whether there relationship between each of services.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -