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