在我的框架,該功能被稱爲無括號....(見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,我可以通過聊天問你幾個跟進問題嗎? –
請先閱讀文檔,然後問我。一切都會在那裏清楚 –