Javascript 带asp.net样板文件的角式喷油器不工作
我正在尝试使用asp.net样板文件附带的角度注入, 我将从这里开始学习“教程” 为了开始我的项目,现在我想将任务作为一部分加载 但由于某种原因,我得到了以下错误:Javascript 带asp.net样板文件的角式喷油器不工作,javascript,asp.net,angularjs,Javascript,Asp.net,Angularjs,我正在尝试使用asp.net样板文件附带的角度注入, 我将从这里开始学习“教程” 为了开始我的项目,现在我想将任务作为一部分加载 但由于某种原因,我得到了以下错误: 错误:[ng:areq]http://errors.angularjs.org/1.3.2/ng/areq?p0=os.views.part.list&p1=not%20aNaNunction%2C%20got%20undefined 错误(本机) 在http://localhost:6234/Scripts/angular.min
错误:[ng:areq]http://errors.angularjs.org/1.3.2/ng/areq?p0=os.views.part.list&p1=not%20aNaNunction%2C%20got%20undefined
错误(本机)
在http://localhost:6234/Scripts/angular.min.js:6:416
在Nb(http://localhost:6234/Scripts/angular.min.js:19:417)
在产科(http://localhost:6234/Scripts/angular.min.js:20:1)
以$get(http://localhost:6234/Scripts/angular.min.js:75:177)
在http://localhost:6234/Scripts/angular.min.js:57:112
在r(http://localhost:6234/Scripts/angular.min.js:7:408)
在我(http://localhost:6234/Scripts/angular.min.js:56:496)
在g(http://localhost:6234/Scripts/angular.min.js:51:299)
在http://localhost:6234/Scripts/angular.min.js:50:414
该应用程序是一个SPA
主应用程序在此处加载:
(function() {
"use strict";
var app = angular.module("app", [
"ngAnimate",
"ngSanitize",
"ui.router",
"ui.bootstrap",
"ui.jq",
"abp"
]);
//Configuration for Angular UI routing.
app.config([
"$stateProvider", "$urlRouterProvider",
function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/");
$stateProvider
.state("home", {
url: "/",
templateUrl: "/App/Main/views/home/home.cshtml",
menu: "Home" //Matches to name of 'Home' menu in OnderdelenshopNavigationProvider
})
.state("about", {
url: "/about",
templateUrl: "/App/Main/views/about/about.cshtml",
menu: "About" //Matches to name of 'About' menu in OnderdelenshopNavigationProvider
})
.state("listParts", {
url: "/list",
templateUrl: "/App/Main/views/parts/list.cshtml",
menu: "ListParts"
});
}
]);
})();
然后,当路由到/列出时,将加载以下JS:
(function() {
var app = angular.module("app");
var controllerId = "os.views.parts.list";
app.controller(controllerId, [
'$scope', 'abp.services.tasksystem.part',
function($scope, partService) {
var vm = this;
vm.localize = abp.localization.getSource("Onderdelenshop");
vm.parts = [];
$scope.selectedTaskState = 0;
$scope.$watch("selectedPartState", function(value) {
vm.refreshParts();
});
vm.refreshParts = function () {
console.log("test");
abp.ui.setBusy( //Set whole page busy until getTasks complete
null,
partService.getParts({ //Call application service method directly from javascript
state: $scope.selectedPartState > 0 ? $scope.selectedPartState : null
}).success(function (data) {
console.log("hey");
vm.parts = data.parts;
})
);
};
vm.changePartState = function(part) {
var newState;
if (part.state === 1) {
newState = 2; //Completed
} else {
newState = 1; //Active
}
partService.updatePart({
partId: part.id,
state: newState
}).success(function() {
part.state = newState;
abp.notify.info(vm.localize("TaskUpdatedMessage"));
});
};
vm.getPartCountText = function() {
return abp.utils.formatString(vm.localize("Xparts"), vm.parts.length);
};
}
]);
})();
这是http://localhost:6234/api/AbpServiceProxies/GetAll?type=angular
(function (abp, angular) {
if (!angular) {
return;
}
var abpModule = angular.module('abp');
abpModule.factory('abp.services.tasksystem.person', [
'$http', function ($http) {
return new function () {
this.getAllPeople = function (httpParams) {
return $http(angular.extend({
abp: true,
url: abp.appPath + 'api/services/tasksystem/person/GetAllPeople',
method: 'POST',
data: JSON.stringify({})
}, httpParams));
};
};
}
]);
})((abp || (abp = {})), (angular || undefined));
(function (abp, angular) {
if (!angular) {
return;
}
var abpModule = angular.module('abp');
abpModule.factory('abp.services.tasksystem.task', [
'$http', function ($http) {
return new function () {
this.getTasks = function (input, httpParams) {
return $http(angular.extend({
abp: true,
url: abp.appPath + 'api/services/tasksystem/task/GetTasks',
method: 'POST',
data: JSON.stringify(input)
}, httpParams));
};
this.updateTask = function (input, httpParams) {
return $http(angular.extend({
abp: true,
url: abp.appPath + 'api/services/tasksystem/task/UpdateTask',
method: 'POST',
data: JSON.stringify(input)
}, httpParams));
};
this.createTask = function (input, httpParams) {
return $http(angular.extend({
abp: true,
url: abp.appPath + 'api/services/tasksystem/task/CreateTask',
method: 'POST',
data: JSON.stringify(input)
}, httpParams));
};
};
}
]);
})((abp || (abp = {})), (angular || undefined));
你知道我可能忘了什么吗
更新1:更进一步;控制器定义必须如下所示:
app.controller(controllerId, [
'$scope', '$location', 'abp.services.tasksystem.part',
function ($scope, $location, partService) { ... }
但是现在出现了内部错误,试图修复该错误,我想知道控制器中的abp是从哪里获得的。您需要注入它更改此行var app=angular.module(“app”);到var app=angular.module(“app”,[]);试试看!!需要方括号才能注册您的帐户app@Asik这是加载在app.js中的(更新了问题)好的。我看到了你的更新。似乎你已经按照Agular 1.3的方式更正了注册控制器的语法。不完全确定,据我所知,这是自动加载的,它防御性地工作,因为我可以从我的其他服务加载来获取所有人