Reputation: 1
var demoApp = angular.module('demoApp', ['ngRoute']);
demoApp.factory = ('simpleFactory', function () {
var factory = {};
var customers = [{ name: 'Touqeer', city: 'Multan' },
{ name: 'Arslan', city: 'RWP' },
{ name: 'Saleem', city: 'Taxila' }];``
factory.getCustomers = function () {
return customers;`enter code here`
};
return factory;
});
demoApp.controller('SimpleController', function ($scope, simpleFactory) {
debugger
$scope.customers = simpleFactory.getCustomers();
});
Error It shows : Error: [$injector:unpr] http://errors.angularjs.org/1.2.14/$injector/unpr?p0=simpleFactoryProvider%20%3C-impleFactory at Error (native)
Upvotes: 0
Views: 169
Reputation: 403
Hy, I made a plunker so you could see into how it should work: Plunker LINK, because I think you will run in to some other stuff too. Stuff that I found to be wrong in the code that you provided:
demoApp.factory = ('simpleFactory', function(){...})
, should be demoApp.factory('simpleFactory', function () {...})
- because you are calling a method, not providing one.//
or /* comment for multiple lines */
,
not just put 'string'Upvotes: 1
Reputation: 691913
demoApp.factory = ('simpleFactory', function () {
should be
demoApp.factory('simpleFactory', function () {
Upvotes: 1