Javascript 当使用控制器作为语法时,控制器值在html中不绑定
我使用控制器作为语法,并尝试在单击按钮时将数据加载到模式中 html: 点击按钮功能:Javascript 当使用控制器作为语法时,控制器值在html中不绑定,javascript,angularjs,angular-material,Javascript,Angularjs,Angular Material,我使用控制器作为语法,并尝试在单击按钮时将数据加载到模式中 html: 点击按钮功能: vm.handleCartOptions = function(data) {debugger $mdDialog.show({ clickOutsideToClose: false, scope: $scope, // use parent scope in template preserveScope: true,
vm.handleCartOptions = function(data) {debugger
$mdDialog.show({
clickOutsideToClose: false,
scope: $scope, // use parent scope in template
preserveScope: true, // do not forget this if use parent scope
template: require('./promptIncludeExcludeDialog/promptIncludeExclude.dialog.html'),
controller: require('./promptIncludeExcludeDialog/promptIncludeExclude.dialog.js'),
controllerAs: "dialogCartController",
locals: {
items: data// on click button value
}
});
}
但是标题、正文和按钮的值并没有绑定到html
如果您定义了
controllerAs:“dialogCartController”
但试图引用vm.title
,我们将不胜感激
请尝试使用
dialogCartController.title
,或controllerAs:“vm”
。您定义了controllerAs:“dialogCartController”
,但尝试引用vm.title
请尝试使用dialogCartController。title,或
controllerAs:“vm”
。这是一个控制器,您能看到我更新的问题吗?这是一个控制器,您能看到我更新的问题吗
(function() {
'use strict';
module.exports = ['$mdDialog', 'items', function($mdDialog, items) {
debugger
var vm = this;
var data = [{
"id": 1,
"title": "Product Inclusion Notification",
"body": "something",
"button1": "proceed",
"button2": "No Thanks"
}
];
angular.forEach(data, function(value, key){
if(value.id==parseInt(items)){
vm.title=value.title;
vm.body=value.body;
vm.button1=value.button1;
vm.button2=value.button2;
}
});
vm.closeDialog = function() {
$mdDialog.hide();
};
}];
})();
vm.handleCartOptions = function(data) {debugger
$mdDialog.show({
clickOutsideToClose: false,
scope: $scope, // use parent scope in template
preserveScope: true, // do not forget this if use parent scope
template: require('./promptIncludeExcludeDialog/promptIncludeExclude.dialog.html'),
controller: require('./promptIncludeExcludeDialog/promptIncludeExclude.dialog.js'),
controllerAs: "dialogCartController",
locals: {
items: data// on click button value
}
});
}