我试图从组件调用控制器的功能。下面是我的文件:从组件调用控制器的功能
controller.js:
$scope.dataTableDevices = {
title: 'title',
color: {'background' : 'rgb(31, 119, 180)'},
items: [0, 1, 2]
};
$scope.hacerClick = function(){
alert("it works");
}
view.html:
<device-categories data="dataTableDevices"></device-categories>
deviceCategories.js:
function deviceCategoriesController() {
}
widgetsFactory.component('deviceCategories', {
templateUrl: 'app/common/js/components/deviceCategories/deviceCategories.html',
controller: deviceCategoriesController,
bindings: {
data: '='
}
});
deviceCategories.html:
<md-button ng-click="howToCallhacerClick()">
Click
</md-button>
检查http://stackoverflow.com/questions/18378520/angularjs-pass-function-to-directive – Shreyas
我一直无法解决这个问题。组件的行为与指令有点不同,对吧? –