html - Error: $injector:unpr Unknown provider: SampleDataProvider -
i having trouble understanding doing wrong importing json data application. dont see calls in console tools , keep getting $injector:unpr error. have written code in controller.js
function caderror($scope, sampledata) { // run method getfulllist() factory sampledata.getfulllist().success(function(data){ // assign data $scope $scope.datafromfactory = data; }); }
and here factories.js sample data reffering to.
function sampledata($http) { // return object return { // create simple method data $http service getfulllist : function() { return $http({ url: 'http://somewebsite/api/example.json', method: 'get' }) } } } angular .module('inspinia') .factory('sampledata', sampledata);
here html using call json data table
<div class="row wrapper border-bottom white-bg page-heading"> <div class="col-lg-10"> <h2>cad error logs</h2> <ol class="breadcrumb"> <li> <a href="index.html">home</a> </li> <li> <a>tables</a> </li> <li class="active"> <strong>data tables</strong> </li> </ol> </div> <div class="col-lg-2"> </div> </div> <div class="wrapper wrapper-content animated fadeinright"> <div class="row"> <div class="col-lg-12"> <div class="text-center m-t-lg"> <h1> simple factory data server </h1> </div> </div> <div class="col-lg-6 col-lg-offset-3"> <div class="ibox"> <div class="ibox-content"> <p class="text-center"> table data api/example.json </p> <table class="table table-striped"> <thead> <tr> <th> id </th> <th> name </th> <th> company </th> <th> description </th> </tr> </thead> <tbody> <tr ng-repeat="item in datafromfactory"> <td> {{item.id}} </td> <td> {{item.name}} </td> <td> {{item.company}} </td> <td> {{item.desc}} </td> </tr> </tbody> </table> </div> </div> </div> </div> </div>
what doing wrong , if more code needed please let me know , post it. read on error , says caused being unable resolve required dependency. how go fixing this. error site of angular js didnt me.
edit
here error message
error: [$injector:unpr] http://errors.angularjs.org/1.5.0/$injector/unpr?p0=sampledataprovider%20%3c-%20sampledata%20%3c-"aderror
i show rest file lines in angular.min.js
this error commonly occurs due problem <script>
references.
the error telling function caderror
looking sampledata
can't find it. commonly occurs when file containing code sampledata
not included in <script>
references, or listed after file needs (the file caderror
in it, in case).
also, should consider not using .success()
in methods, since has been deprecated. see why angular $http success/error methods deprecated? removed v1.6?
Comments
Post a Comment