0
指令不調用我的控制器方法。以下是我的代碼:爲什麼指令不會調用我的控制器方法?
控制器:
exports.controller = ['$scope', function($scope) {
$scope.addParamter = function() {
console.log("here");
};
$scope.editParamter = function (item) {
console.log(item);
};
}];
頁:
<formula-editor
add-paramter="addParameter()"
edit-paramter="editParameter(item)">
</formula-editor>
指令:
JS:
exports.inject = function(app) {
app.directive('formulaEditor', exports.directive);
return exports.directive;
};
exports.directive = function() {
return {
restrict: 'E',
templateUrl: '/dist/views/formula-editor.html',
scope: {
addParameter: '&',
editParameter: '&'
}
};
};
配方editor.html:
<button ng-click="addParameter()"></button>
向我們展示控制器的用法,你在哪裏引用它? –
修正你的拼寫錯誤在html:'add-parameter'和'edit-parameter' – devqon