【发布时间】:2017-11-07 04:58:43
【问题描述】:
在我的框架中,函数调用时不带括号......(参见 showErrors)
(function () {
'use strict';
angular
.module('core')
.directive('showErrors', showErrors);
showErrors.$inject = ['$timeout', '$interpolate'];
function showErrors($timeout, $interpolate) {
var directive = {
restrict: 'A',
require: '^form',
compile: compile
};
return directive;
我知道它是如何工作的......但是当我尝试这个时,我的组件将无法工作。仅当我将其更改为 .component('hotkeys', HotkeysComponent()); // 为 HotkeysComponent 添加括号
angular
.module('contacts.components')
.component('hotkeys', HotkeysComponent);
function HotkeysComponent() {
var component = {
templateUrl: '/my-app/contacts/client/views/ui/hotkeys.ui.html',
controller: 'AddManagerController',
controllerAs: 'vm'
};
return component;
澄清一下,除非我执行 HotkeysComponent(),否则它不会起作用
angular
.module('contacts.components')
.component('hotkeys', HotkeysComponent()); // why don't the other functions need ()?
【问题讨论】:
标签: angularjs components