【发布时间】:2016-10-14 00:01:11
【问题描述】:
在directives文件夹中我创建了两个文件:directives.js和color.js
directives 我已经导入 app.js
directives.js:
import angular from 'angular';
import ColorDirective from './color';
const moduleName = 'app.directives';
angular.module(moduleName, [])
.directive('color', ColorDirective);
export default moduleName;
color.js
import angular from 'angular';
let ColorDirective = function () {
return {
link: function (scope, element) {
console.log('ColorDirective');
}
}
}
export default ColorDirective;
在组件中的一个元素上,我添加了 color 作为 attr。
但它不起作用。我的意思是内部链接循环。为什么?我有什么错误的编码?如何使用 angular 1.5 & es2016 的指令?
【问题讨论】:
-
也许你只需要写
return response.data?取决于您返回的休息对象。 -
只返回 MyService.getData(),不带 .then(....) 部分。 uid-typehead 期待一个承诺
-
我没有使用过 resangular,所以我不确定它会返回什么。尝试将 $q 服务添加到您的控制器,并返回 $q.resolve(response) 而不是返回响应 - 这将返回一个将通过响应解决的承诺。
-
很高兴在 plunker 的某个地方看到整个应用程序
标签: javascript angularjs ecmascript-6