Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs [ng:areq] Argument 'fn' is not a function, got string

Tags:

I am new to angular js..I am getting follwing error please help me out

[ng:areq] Argument 'fn' is not a function, got string

var app = angular.module('demo',[]);   app.config('$routeProvider',function($routeProvider){      $routeProvider.when('/add',{         templateUrl:'demo/add.html',         controller:'addcontroller'     }).     when('/order',{         templateUrl:'demo/order.html',         controller:'ordercontroller'     });  });  app.controller('addcontroller',function($scope){     $scope.message="order"; }); app.controller('ordercontroller',function($scope){     $scope.message="order"; }); 
like image 913
pavan Avatar asked May 12 '14 06:05

pavan


1 Answers

I think the error is in the config block, it should either be:

app.config(function($routeProvider){   // routeProvider config }); 

or better:

app.config(['$routeProvider', function($routeProvider){   // routeProvider config, allows minification }]); 

the annotations are there for minification to work correctly. You can read more about it on AngularJS docs https://docs.angularjs.org/tutorial/step_05 Please note that this practice needs to be done throughout the app to work correctly.

like image 105
wiherek Avatar answered Dec 14 '22 23:12

wiherek