2015-02-06 74 views
0

我有这样的代码在我的index.html页面呼叫输入值angularjs

<div class=" property_value col-md-1" style="width: 13%; padding-left: 0px; padding-right: 2px"> 
    <h6>Property Value(RM)</h6> 
    <input id="property_value" name="property_value" type="text" placeholder="500000" value="500000" ng-model="loanfilter.property_value" class="form-control property-value-input" style="height: 20px" /> 
</div> 

在我index.js控制器文件,我有这个功能应该调用属性的值

$scope.paramsData = function() { 
     params = { 
      landType: $scope.loanfilter.land_type, 
     property: '$scope.loanfilter.property_type, 
     }; 
     return param; 
}; 

但它似乎没有工作。我怎么能从angularjs的视图调用这个值到控制器。

感谢

+0

为什么你在''''$'scope.loanfilter.property_type'之间''? – levi 2015-02-06 02:43:36

+0

在您的视图中,您引用了loanfilter.property_value,但在js对象中引用了loanfilter.property_type,它们需要保持一致。此外,没有必要为'你有财产后:和$范围之前。此外,你的回报,你声明的对象params,但告诉它返回参数,再次两个不同的变量。 – ThatTechGuy 2015-02-06 02:50:42

+0

@ThatTechGuy很好的评论,但这不是问题。主要的问题是我需要为我的表单添加一个名称,然后根据它们的名称和值调用每个输入的d值,以便formName.inputTypeName.value。 – 2015-02-10 06:01:15

回答

0

确保申报loanfilterloanfilter.property_value$scope靠近你的控制器的顶部。这样,绑定应该发生。

$scope.loanfilter = {}; 
$scope.loanfilter.property_value = ''; 

希望有帮助。