I am having trouble understanding what I am doing wrong with importing json data into my application. I dont see any get calls in the console tools and I keep getting a $injector:unpr error. I have written this code in the controller.js
function caderror($scope, SampleData) {
// Run method getFullList() from factory
SampleData.getFullList().success(function(data){
// Assign data to $scope
$scope.dataFromFactory = data;
});
}
and here is factories.js where the sample data is reffering to.
function SampleData($http) {
// Return the object
return {
// Create simple method to get data from $http service
getFullList : function() {
return $http({
url: 'http://somewebsite/api/example.json',
method: 'GET'
})
}
}
}
angular
.module('inspinia')
.factory('SampleData', SampleData);
Here is the HTML I am using to call the JSON data into a 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 to get data from 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 with data from 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 am i doing wrong and if any more code is needed please let me know and i will post it. I read up on the error and it says it caused by being unable to resolve a required dependency. How would I go about fixing this. the error site of angular js didnt really help me.
EDIT
Here is the error message
Error: [$injector:unpr] http://errors.angularjs.org/1.5.0/$injector/unpr?p0=SampleDataProvider%20%3C-%20SampleData%20%3C-"aderror
I could show the rest but they are just file lines in angular.min.js