0

这里是指令角指令模板阵列中的控制器功能

directives.directive("unitDirective", function(){ 
    return { 
    templateUrl: "../html/directives/unitDir.html" 
    } 
}); 

这里是模板

<div ng-repeat="unit in addUnit()"> 
    <label class="item item-input"> 
    <span class="input-label">Unit {{unit+1}}</span> 
    <input type="number" placeholder="enter estimated monthly rent" ng-model="units.price[$index]"> 
    </label> 
    </div> 

这里就是我想按钮是

<ion-view> 
    <ion-content> 

    <unit-directive></unit-directive> 
    <button class="button buttomn-assertive">Confirm</button> 

    </ion-content> 
</ion-view> 

这里是我的控制器:

controllers.controller("unitsCtrl", function($scope, $stateParams){ 

    $scope.units = { 
     price: [1,2] 
    } 
    $scope.addUnit = function(){ 
     var dummyArray = []; 
     for(var i =0; i < $stateParams.units; i++){ 
     dummyArray[i] = i; 
     } 
     return dummyArray; 
    }; 

    $scope.calculate= function(){ 

     //how do I access the array of units prices here? 
    } 

    }); 

基本上,我使用cordovadialog插件来询问他们想要创建多少个单元,然后用提供的数字制作了一个虚拟数组,并将其用于ng-repeat。现在,我必须接受所有的输入并将它们存储在一个数组中,并且我被卡住了。 对任何其他可能的重复问题,解决方案或文档/教程的任何一般方向将不胜感激。

回答

0

固定它!!而不是指令是一个完全不同的模块,我将指令更改为控制器模块的指令,我尝试访问该值。

相关问题