如何修复此范围以HTML格式显示

时间:2015-08-30 05:05:18

标签: javascript html angularjs html5

我在功能上有$ scope但这个$ scope不能在html中显示如何让它显示?

  

这个代码在fucntion

$scope.checkBrach = function(index) {
    console.log($scope.dataBranch[index]);
    $scope.branchCode = $scope.dataBranch[index].branch_code;
}
  

HTML中的代码和{{branchCode}}不为我显示数据

                                                           ×                     รายชื่อสาขา                                                                                                                                                                                                                                                             选择                                                                                                                                                                 {{i.branch_code}}                                     {{i.branch_name}}                                                                                                                           建立                                                                                                                               删除                                                                                                                                                                                                                                                                          关                         好                     

                                           
<div aria-hidden="true" class="modal fade" id="delete-branch" role="dialog" tabindex="-1" ng-controller="contestCtrl">
    <div class="modal-dialog modal-xs">
        <div class="modal-content">
            <div class="modal-heading">
                <a class="modal-close" data-dismiss="modal">&times;</a>
                <h2 class="modal-title">Modal Title</h2>
            </div>
            <div class="modal-inner">
                <p>
                    <strong>{{branchCode}}</strong>
                </p>
            </div>
            <div class="modal-footer">
                <p class="text-right">
                    <button class="btn btn-flat btn-alt" data-dismiss="modal" type="button">Close</button>
                    <button class="btn btn-flat btn-alt" data-dismiss="modal" type="button">OK</button>
                </p>
            </div>
        </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:1)

为了设置$scope.branchCode的值,您必须运行函数$scope.checkBrach,因为范围变量branchCode是在该函数内创建的,或者您可以在控制器顶部定义变量,如{ {1}}。