【发布时间】:2014-10-23 16:35:59
【问题描述】:
嘿,我有两个 JSP 页面,它们是表单的第 1 步和第 2 步。在第 1 步中,我正在显示用户可以选择的某些类别选项。为了让用户进入第 2 步,他们必须单击其中一个类别选项,然后在进入第 2 步时,我试图显示他们单击的类别的名称。我知道使用 ng-model,可以将其绑定到输入并显示在该输入中交互的内容,但由于某种原因,如果我将 ng-model 绑定到“p”或“span”,它就无法工作。我是 AngularJs 的新手,所以请避免任何新手错误。
step_one.jsp
<div class="col-sm-6" ng-click="setStep(2)"><span class="glyphicon glyphicon-cutlery"></span>
<p ng-model="category">Cutlery & Service</p>
</div>
step_two.jsp
<div class="col-md-12">
<label for="requestCategory">Category:</label>
<p id="requestCategory" ng-model="category">{{category}}</p>
</div>
JS切换步骤:
$scope.setStep = function (step){
$scope.step = step;
};
$scope.isStepSet = function(step){
return ($scope.step === step) ;
};
【问题讨论】:
标签: angularjs angularjs-directive angular-ngmodel