我正在尝试将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'])
我只是在没有加载模板的情况下得到一个空白页面,没有任何错误消息。
我正在尝试遵循this教程的Javascript动画部分。
任何洞察力/帮助表示感谢。
答案 0 :(得分:2)
如果您尝试向模块添加动画,那么我相信您希望代码看起来像这样:
CREATE TABLE `tbl` (
`id` BIGINT UNSIGNED NOT NULL PRIMARY KEY,
`born` DATE
);
CREATE TRIGGER `tbl_trg_ins` BEFORE INSERT ON `tbl`
FOR EACH ROW
BEGIN
IF (NEW.`born` < '1900-01-01' OR NEW.`born` > '1999-12-31') THEN
SIGNAL SQLSTATE '10000'
SET MESSAGE_TEXT = 'check constraint on tbb failed during insert';
END IF;
END;
CREATE TRIGGER `tbl_trg_upd` BEFORE UPDATE ON `tbl`
FOR EACH ROW
BEGIN
IF (NEW.`born` < '1900-01-01' OR NEW.`born` > '1999-12-31') THEN
SIGNAL SQLSTATE '10000'
SET MESSAGE_TEXT = 'check constraint on tbl failed during update';
END IF;
END;
INSERT INTO `tbl`
VALUES (1, '1990-12-12');
-- INSERT INTO `tbl`
-- VALUES (2, '2001-12-12');
-- 'check constraint on tbb failed during insert'
答案 1 :(得分:1)
你在.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");
}
}
});