在我的框架,该功能被称为无括号....(见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()?
谢谢!所以这个对象是独一无二的组件在角.. –
Mr_Perfect,我可以通过聊天问你几个跟进问题吗? –
请先阅读文档,然后问我。一切都会在那里清楚 –