我在$dialogScope.items中有此下拉列表,但是我尝试在函数selectChange中调用,但它似乎不起作用。请帮助我注意错误

这是从html部分

<div class="form-group has-feedback">
 <label class="control-label">Type</label><br/>
  <select class="form-control" ng-model="selectedItem" ng-change="selectChange()" ng-options="item as item.name for item in items">
   <option value=""> Select Type</option>
  </select>
</div>


更新

 $scope.addStep = function (patchID) {
    $dialog.open({
        showClose: false,
        closeByEscape: true,
        template: 'views/app-edit/app-edit-patch-step-add.html',
        controller: ['$scope', function ($dialogScope) {
            $dialogScope.items = [{
                name:"Download APK",
                value:"0",
            },{
                name:"Backup",
                value:"1"
            },{
                name:"Restore",
                value:"2",
            },{
                name:"Download OBB",
                value:"4",
            },{
                name: "Download OBB By GPU",
                options : ["Adreno","Mali","Tegra","PowerVR","Other"]
            },{
                name: "Download APK By GPU",
                options : ["Adreno","Mali","Tegra","PowerVR","Other"]
            },{
                name: "Download CACHE",
                value:"7",
            },{
                name: "Download CACHE By GPU",
                value:"8",
            },{
                name: "Download CACHE & Unzip After Install",
                value:"9",
            },{
                name: "Download CACHE By GPU & Unzip After Install",
                value:"10",
            },
            ];
            $dialogScope.hideMe = function(hideElements){
                if($dialogScope.selectedItem){
                    return (hideElements.indexOf($dialogScope.selectedItem.name) != -1)?false:true;
                }
                else{
                    return true;
                }
            }
            $dialogScope.selectChange = function(selectedItem){
                if (selectedItem.value) {
                    $dialogScope.type = selectedItem.value;
                    $dialogScope.labelA = 'dferfre';
                    $dialogScope.labelB = '';
                    $dialogScope.labelC = 'MD5';
                    $dialogScope.stepA = '';
                    $dialogScope.stepB = '';
                    $dialogScope.stepC = '';
                    if (value == 0) {
                         $dialogScope.labelA = "APK URL";
                     } else if (value == 4) {
                         $dialogScope.labelA = "OBB URL";
                     } else if (value == 5) {
                         $dialogScope.labelB = "OBB URL";
                     } else if (value = 6) {
                         $dialogScope.labelB = "APK URL";
                     }


                    $dialogScope.$apply();
                }
            };

最佳答案

将模型传递到函数中。尝试这个。

<select class="form-control" ng-model="selectedItem" ng-change="selectChange(selectedItem)" ng-options="item as item.name for item in items">

10-04 21:48
查看更多