Javascript AngularJS:服务错误,未定义服务。我做错了什么?
当我使用$http服务时,它工作得很好,但我想让它成为RESTful。我现在有错误了。有人能把我踢向正确的方向吗?我做错了什么 app.js:Javascript AngularJS:服务错误,未定义服务。我做错了什么?,javascript,angularjs,Javascript,Angularjs,当我使用$http服务时,它工作得很好,但我想让它成为RESTful。我现在有错误了。有人能把我踢向正确的方向吗?我做错了什么 app.js: 'use strict'; angular .module('swoleincApp', [ 'ngRoute', 'ngSanitize', 'ngAnimate', 'ngResource' ]) .config(['$routeProvider', '$loc
'use strict';
angular
.module('swoleincApp', [
'ngRoute',
'ngSanitize',
'ngAnimate',
'ngResource'
])
.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider
.when('/models', {
templateUrl: 'app/views/main.html',
controller: 'MainCtrl'
})
.when('/models/:modelId', {
templateUrl: 'app/views/individual.html',
controller: 'ProfileCtrl'
})
.otherwise({
redirectTo: '/models'
});
$locationProvider.html5Mode(true);
}]);
'use strict';
angular
.module('swoleincApp')
.factory('Profile', ['$resource', ProfileService]);
function ProfileService($resource) {
return $resource('app/storage/individual/:modelId.json', {}, {
query: {
method: 'GET',
params: {
modelId: 'individual'
},
isArray: true
}
});
}
'use strict';
angular
.module('swoleincApp')
.controller('ProfileCtrl', ['$scope', ProfileCtrl]);
function ProfileCtrl($scope) {
$scope.profile = Profile.query();
}
ProfileService.js:
'use strict';
angular
.module('swoleincApp', [
'ngRoute',
'ngSanitize',
'ngAnimate',
'ngResource'
])
.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider
.when('/models', {
templateUrl: 'app/views/main.html',
controller: 'MainCtrl'
})
.when('/models/:modelId', {
templateUrl: 'app/views/individual.html',
controller: 'ProfileCtrl'
})
.otherwise({
redirectTo: '/models'
});
$locationProvider.html5Mode(true);
}]);
'use strict';
angular
.module('swoleincApp')
.factory('Profile', ['$resource', ProfileService]);
function ProfileService($resource) {
return $resource('app/storage/individual/:modelId.json', {}, {
query: {
method: 'GET',
params: {
modelId: 'individual'
},
isArray: true
}
});
}
'use strict';
angular
.module('swoleincApp')
.controller('ProfileCtrl', ['$scope', ProfileCtrl]);
function ProfileCtrl($scope) {
$scope.profile = Profile.query();
}
ProfileCtrl.js:
'use strict';
angular
.module('swoleincApp', [
'ngRoute',
'ngSanitize',
'ngAnimate',
'ngResource'
])
.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider
.when('/models', {
templateUrl: 'app/views/main.html',
controller: 'MainCtrl'
})
.when('/models/:modelId', {
templateUrl: 'app/views/individual.html',
controller: 'ProfileCtrl'
})
.otherwise({
redirectTo: '/models'
});
$locationProvider.html5Mode(true);
}]);
'use strict';
angular
.module('swoleincApp')
.factory('Profile', ['$resource', ProfileService]);
function ProfileService($resource) {
return $resource('app/storage/individual/:modelId.json', {}, {
query: {
method: 'GET',
params: {
modelId: 'individual'
},
isArray: true
}
});
}
'use strict';
angular
.module('swoleincApp')
.controller('ProfileCtrl', ['$scope', ProfileCtrl]);
function ProfileCtrl($scope) {
$scope.profile = Profile.query();
}
当我加载models/:modelId页面时,该页面将分别加载已单击的modelId,但angular没有编译或其他内容,我只会在其中获得带字符串的括号
我也会遇到这个错误(注意,我将Laravel与Homestead和VirtualBox一起使用):
ReferenceError:未定义配置文件
在新的ProfileCtrl(http://laravel.app/app/js/controllers/ProfileCtrl.js:8:19)
在e(http://laravel.app/app/js/dependencies/angular.min.js:39:193)
在Object.instantiate(http://laravel.app/app/js/dependencies/angular.min.js:39:310)
在http://laravel.app/app/js/dependencies/angular.min.js:80:313
在A.link(http://laravel.app/app/js/dependencies/angular-route.min.js:7:268)
在aa(http://laravel.app/app/js/dependencies/angular.min.js:73:90)
在K(http://laravel.app/app/js/dependencies/angular.min.js:62:39)
在g(http://laravel.app/app/js/dependencies/angular.min.js:54:410)
在http://laravel.app/app/js/dependencies/angular.min.js:53:480
在http://laravel.app/app/js/dependencies/angular.min.js:55:397 (匿名函数)@angular.min.js:107
http://laravel.app/models/dom 加载资源失败:服务器响应状态为404(未找到)
似乎在控制器中
function ProfileCtrl($scope) {
$scope.profile = Profile.query();
}
您没有在配置文件工厂中注入配置文件 似乎在您的控制器中
function ProfileCtrl($scope) {
$scope.profile = Profile.query();
}
您没有在配置文件工厂中注入配置文件 似乎在您的控制器中
function ProfileCtrl($scope) {
$scope.profile = Profile.query();
}
您没有在配置文件工厂中注入配置文件 似乎在您的控制器中
function ProfileCtrl($scope) {
$scope.profile = Profile.query();
}
您没有在配置文件工厂中注入配置文件