angularJS显示空白页面没有错误-控制器问题
angularJS displaying blank page without errors - controller issues
我正在尝试将ngAnimate指令写入控制器。我在一个单独的文件中加载我的应用程序,并像这样配置路线:
angular
.module('CurriculumApp', ['ui.router', 'ngAnimate'])
.config(function($stateProvider, $urlRouterProvider) {
//catchall route points to landing
$urlRouterProvider.otherwise("/landing")
//app routes
$stateProvider
//landing page
.state('landing', {
url: '/landing',
templateUrl: '/../views/landing.html'
})
//skills page
.state('skills', {
url: '/skills',
templateUrl: '/../views/skills.html'
})
//portfolio page
.state('portfolio', {
url: '/portfolio',
templateUrl: '/../views/portfolio.html',
controller: 'portfolioController'
});
});
现在,如果我在没有依赖项的情况下初始化我的控制器(这是一个单独的.js文件):
angular
.module('CurriculumApp')
//portfolio controller
.controller('portfolioController', function($scope) {
.animation ('.img-thumbnail', function() {
return {
move: function(element, done) {
$(element).toggle("bounce", { times : 3 }, "slow");
}
}
}); //closes .animation
})// closes controller
我得到以下错误:
Error: (intermediate value).animation is not a function
但当我尝试像主应用程序一样初始化它时:
.module('CurriculumApp', ['ui.router', 'ngAnimate'])
我只得到一个空白页面,没有加载模板,也没有任何错误消息。
我正在努力学习本教程的Javascript动画部分。
感谢您的任何见解/帮助。
如果您正试图将动画添加到您的模块中,那么我相信您希望您的代码看起来像这样:
angular.module('CurriculumApp')
//portfolio controller
.controller('portfolioController', function($scope) {
// Controller stuff goes here
})// closes controller
.animation ('.img-thumbnail', function() {
return {
move: function(element, done) {
$(element).toggle("bounce", { times : 3 }, "slow");
}
}
}); //closes .animation
.animation
的左侧没有任何内容,这就是它无法工作的原因(如果您删除空白,本质上就是function($scope){.animation(...
,即您在无内容的情况下调用动画方法,这就是您收到错误的原因。
我认为.animation方法应该在模块上调用,即这应该起作用:
angular
.module('CurriculumApp')
.controller('portfolioController', function($scope) {
})
.animation ('.img-thumbnail', function() {
return {
move: function(element, done) {
$(element).toggle("bounce", { times : 3 }, "slow");
}
}
});
相关文章:
- 回复'js'仅当请求有错误时(否则使用html)
- 表单已发送,但验证有错误
- 如果文件不存在,fs.watch是否有错误处理程序
- Meteor上有错误的同步问题
- 表单验证:如果有错误,不要't使手风琴动起来
- 我有错误文档.注册元素未被细化
- 如何转换为特定于 json 的类 c#?我有错误
- 如果当前输入有错误或警告,则禁用所有下一个表单输入字段
- 通过有错误的 Ajax-Request 打印出 HTML 会阻止进一步的 JS 工作
- 脸书应用程序有错误
- XDomainRequest 总是有错误
- HTML5 Canvas游戏有错误,点击时第一个拼图块会变成不同的块
- Page_ClientValidate返回 false,但没有一个验证器有错误
- AngularJS错误 - “控制器未定义”或“未定义函数”
- 量角器由中继器命令中是否有错误
- Jquery 验证器 - 表单被保存但有错误
- 任何人看到我的重置功能有错误
- 现在我有错误“;ReferenceError:项未定义“;不知道如何测试我的dataService
- 有没有一种方法可以在加载页面后检查iframe是否有错误消息
- 我可能对hoverIntent有错误的想法