- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
这不太可能,但是有人以前见过这个错误吗?我正在尝试使用 express、angular 和 mongoDB 添加“Transporters”。每当我访问由传输 Controller 控制的页面时,我都会收到此错误:
Error: [ng:areq] http://errors.angularjs.org/1.2.12/ng/areq?p0=TransportersController&p1=not%20aNaNunction%2C%20got%20undefined
at Error (native)
at http://localhost:3000/lib/angular/angular.min.js:6:450
at tb (http://localhost:3000/lib/angular/angular.min.js:18:360)
at Pa (http://localhost:3000/lib/angular/angular.min.js:18:447)
at http://localhost:3000/lib/angular/angular.min.js:62:17
at http://localhost:3000/lib/angular/angular.min.js:49:43
at q (http://localhost:3000/lib/angular/angular.min.js:7:386)
at H (http://localhost:3000/lib/angular/angular.min.js:48:406)
at f (http://localhost:3000/lib/angular/angular.min.js:42:399)
at http://localhost:3000/lib/angular/angular.min.js:42:67
运输车 Controller 看起来像这样:
'use strict';
angular.module('mean.transporters').controller('TransportersController', ['$scope', '$routeParams', '$location', 'Global', 'Transporters', function ($scope, $routeParams, $location, Global, Transporters) {
$scope.global = Global;
$scope.create = function() {
var transporter = new Transporters({
name: this.name,
natl_id: this.natl_id,
phone: this.phone
});
transporter.$save(function(response) {
$location.path('transporters/' + response._id);
});
this.title = '';
this.content = '';
};
$scope.remove = function(transporter) {
if (transporter) {
transporter.$remove();
for (var i in $scope.transporters) {
if ($scope.transporters[i] === transporter) {
$scope.transporters.splice(i, 1);
}
}
}
else {
$scope.transporter.$remove();
$location.path('transporters');
}
};
$scope.update = function() {
var transporter = $scope.transporter;
if (!transporter.updated) {
transporter.updated = [];
}
transporter.updated.push(new Date().getTime());
transporter.$update(function() {
$location.path('transporters/' + transporter._id);
});
};
$scope.find = function() {
Transporters.query(function(transporters) {
$scope.transporters = transporters;
});
};
$scope.findOne = function() {
Transporters.get({
transporterId: $routeParams.transporterId
}, function(transporter) {
$scope.transporter = transporter;
});
};
}]);
在我看来,我调用列表并创建方法。他们产生上述错误
我从 ng:areq 的 Angular 文档中得到了这个虽然还是搞不懂是怎么回事
AngularJS often asserts that certain values will be present and truthy using a helper function. If the assertion fails, this error is thrown. To fix this problem, make sure that the value the assertion expects is defined and truthy.
这是调用 Controller 的 View public/views/transporters/list.html
:
<section data-ng-controller="TransportersController" data-ng-init="find()">
<ul class="transporters unstyled">
<li data-ng-repeat="transporter in transporters">
<span>{{transporter.created | date:'medium'}}</span> /
<h2><a data-ng-href="#!/transporters/{{transporter._id}}">{{transporter.name}}</a></h2>
<div>{{transporter.natl_id}}</div>
<div>{{transporter.phone}}</div>
</li>
</ul>
<h1 data-ng-hide="!transporters || transporters.length">No transporters yet. <br> Why don't you <a href="/#!/transporters/create">Create One</a>?</h1>
</section>
运输服务代码:
angular.module('transporterService', [])
.factory('Transporter', ['$http', function($http){
// all return promise objects
return {
get: function(){
return $http.get('/api/transporters');
},
create: function(transporterData){
return $http.post('/api/transporters', transporterData);
},
delete: function(id){
return $http.delete('/api/transporters/'+id);
}
};
}]);
最佳答案
我遇到过一次这个错误。问题是我在两个地方用不同的参数定义了 angular.module()。
例如:
var MyApp = angular.module('MyApp', []);
在其他地方,
var MyApp2 = angular.module('MyApp', ['ngAnimate']);
关于javascript - 错误 : [ng:areq] from angular controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21673404/
我需要一些帮助。只需要学习 Angular,我就是这样设置的。 这是我的文件结构。 关于Controller.js function AboutController( $scope ){ $sco
我有 Angular JS 的实践项目,描述 demoangular.html 页面 Logout.html 页面 demoangular 页面是登录页面,它重定向到 logout.html 但是 l
我是 angularjs 的新手,想知道我的代码有什么问题。我正在学习教程,但由于这个错误而卡住了。 索引.php AngularJS {{data.mes
我收到一个[ng:areq]错误,可能很愚蠢,但我没有看穿它。 做了一些研究发现没有什么帮助。 演示代码: Angular Third Example
我是angularjs的初学者 我有前端代码 Scope Data
我已经检查了有关错误 Error: [ng:areq] 的其他解决方案,大多数都说明了缺少文件功能、变量重复或覆盖模块的原因。我的controller.js代码如下,它似乎没有任何这些问题。 var
我正在尝试在 angularjs 中过滤搜索结果,但在 chrome 控制台上收到此错误:错误:[ng:areq] 这是我的代码片段 By name Newest
我已经设置了 Angular Factory 和 Controller ,以使用其 API 从 Instagram 中提取图像。我在尝试加载页面时遇到错误,但似乎无法找出问题所在。我的 html、应用
你能解释一下为什么下面的代码返回 Error: error:areqBad Argument ? (参见 live example ) function Simple
这个问题在这里已经有了答案: Controller not a function, got undefined, while defining controllers globally (14 个答
我试图让我的元 Controller 动态更改元标记,但在控制台中我收到错误 ng areq not a function。我在 StackOverflow 中搜索了类似的问题,但没有一个解决方案适合
这不太可能,但是有人以前见过这个错误吗?我正在尝试使用 express、angular 和 mongoDB 添加“Transporters”。每当我访问由传输 Controller 控制的页面时,我都
我正在尝试在我的 rails 应用程序中加载一个空白的谷歌地图应用程序(稍后我将通过 facotries 等添加标记)。这种格式在我的上一个项目中有效,但不幸的是这次我无法加载它。 我通过 bower
我试图用 Angular 制作一个简单的应用程序,我偶然发现了 页面加载时弹出错误。我做错了什么? views/raffle/index.html.erb Raffler
我正在开发一个新的作品集网站,希望使用 AngularJS 来显示我的作品,并使用纯 css 来格式化布局等。 我找到了一个有用的教程,概述了如何构建应用程序以供将来扩展,并设置了如下所示的文件树:
我是 Angular js 新手..我遇到以下错误,请帮助我 [ng:areq] 参数“fn”不是函数,而是字符串 var app = angular.module('demo',[]); app.c
出现以下错误 Error: [ng:areq] Argument 'nameController' is not a function, got undefined http://errors.ang
为什么我的 ProjectsController 未定义?我从浏览器控制台收到此错误消息。 你可以自己检查看看这个plunker: http://plnkr.co/edit/0DJ6W7QEPx2Uz
我正在尝试使用 Django 进行 Angular 工作。我非常困难地让它与 Django 和 Angular 一起工作,但现在我又遇到了一个错误。每次加载它时,我都会收到以下错误。 Error: [
当我尝试使用 ngmockE2E 模拟后端时出现错误。 “angularjs [ng:areq] 参数 'fn' 不是函数,得到字符串” 当我删除 ngMock 服务时,它工作正常。 索引.html
我是一名优秀的程序员,十分优秀!