Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当使用控制器作为语法时,控制器值在html中不绑定_Javascript_Angularjs_Angular Material - Fatal编程技术网

Javascript 当使用控制器作为语法时,控制器值在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,

我使用控制器作为语法,并尝试在单击按钮时将数据加载到模式中

html:

点击按钮功能:

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
            }
        });

    }