我正在将我的crud angular.9升级到1.3,这样做后我意识到两者之间的巨大变化。由于我不是有角度的大师,所以我决定寻求社区帮助解决这个令人讨厌的错误。 这是我有的: 我的index.php
<!DOCTYPE HTML>
<html xmlns:ng="http://angularjs.org" ng-app="crm" >
<head>
<title>CRM</title>
</head>
<body ng-controller="RouteCtrl" >
<div id="content" class="">
<ng-view></ng-view>
</div>
<script src="lib/angularjs/angular.js" ng-autobind></script>
<script src="lib/angularjs/angular-resource.js"></script>
<script src="lib/angularjs/angular-route.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
</body>
</html>
和我的services.js:
angular.module('crm',['ngResource','ngRoute'])
.config(['$locationProvider', '$routeProvider' , function($locationProvider, $routeProvider) {
$routeProvider.
when('/leads', { templateUrl:'tpl/leads.php', controller:LeadListCtrl }).
when('/leads/add', {controller:LeadListCtrl, templateUrl:'tpl/leads.php'}).
when('/leads/:leadId', { templateUrl:'tpl/leads.php', controller:LeadDetailCtrl , resolve: LeadDetailCtrl.resolve}).
when('/customers', { templateUrl:'tpl/customers.php', controller:CustomerDetailCtrl }).
when('/customers/:customerId', { templateUrl:'tpl/customers.php', controller:CustomerDetailCtrl }).
otherwise({templateUrl:'tpl/welcome.php'});
}]).
factory('Lead', ['$resource', function($resource) {
return $resource('api/leads/:leadId', {},
{ 'update': { method:'PUT' }
});
}]).
factory('Customer', [function ($resource) {
return $resource('api/customers/:customerId', {}, {
update: {method:'PUT'}
});
}]);
处理程序:
function CustomerListCtrl(Customer){
this.customers = Customer.query();
}
function CustomerDetailCtrl(Customer) {
var currentnotes;
this.customer = Customer.get({customerId: this.params.customerId});
}
这是我的错误:
TypeError: undefined is not a function
at Object.<anonymous> (http://localhost/crm_2/js/services.js:51:16)
at Object.invoke (http://localhost/crm_2/lib/angularjs/angular.js:4185:17)
at Object.enforcedReturnValue [as $get] (http://localhost/crm_2/lib/angularjs/angular.js:4038:37)
at Object.invoke (http://localhost/crm_2/lib/angularjs/angular.js:4185:17)
at http://localhost/crm_2/lib/angularjs/angular.js:4003:37
at getService (http://localhost/crm_2/lib/angularjs/angular.js:4144:39)
at invoke (http://localhost/crm_2/lib/angularjs/angular.js:4176:13)
at Object.instantiate (http://localhost/crm_2/lib/angularjs/angular.js:4193:27)
at http://localhost/crm_2/lib/angularjs/angular.js:8462:28
at link (http://localhost/crm_2/lib/angularjs/angular-route.js:975:26) <div ng-view="" class="ng-scope">
任何帮助将不胜感激: - )
答案 0 :(得分:1)
请正确添加依赖项。
var crm = angular.module('crm',['ngResource','ngRoute']);