Javascript 数据未绑定到Angularjs中的UI
数组不会在UI中绑定,在下面的示例中Javascript 数据未绑定到Angularjs中的UI,javascript,arrays,angularjs,Javascript,Arrays,Angularjs,数组不会在UI中绑定,在下面的示例中 在Html中,我使用了数据表 $scope.successMessage变量也未绑定到UI 我试过很多方法,但都不管用 Html页面: <div class="box-body table-responsive"> <table id="mktable" datatable="ng" class="table table-bordered" dt-options="dtOptions"> <thea
在Html中,我使用了数据表
$scope.successMessage变量也未绑定到UI 我试过很多方法,但都不管用 Html页面:
<div class="box-body table-responsive">
<table id="mktable" datatable="ng" class="table table-bordered"
dt-options="dtOptions">
<thead>
<tr>
<th>Account Number</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="rows in accNum">
<td>{{rows.ID}}</td>
</tr>
</tbody>
</table>
</div>
以上代码行有什么问题?检查您是否已在模板中包含
ng app
和ng controller
演示
var-app=angular.module('testApp',[]);
app.controller('testCtrl',函数($scope){
$scope.accNum=[{“ID”:“30901259753”},{“ID”:“30900137788”},{“ID”:“30901335532”}];
});代码>
{{accNo.ID}
它工作得非常好。以下是完整的代码:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp">
<table ng-controller="myCtrl" border="1">
<tr ng-repeat="x in accNum">
<td>{{x.ID}}</td>
</tr>
</table>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.accNum=[{"ID":"309001259753"},{"ID":"309000137788"}, {"ID":"309001335532"}]
});
</script>
</body>
</html>
{{x.ID}
var-app=angular.module(“myApp”,[]);
app.controller(“myCtrl”,函数($scope){
$scope.accNum=[{“ID”:“30901259753”},{“ID”:“30900137788”},{“ID”:“30901335532”}]
});
请,您需要共享更多代码以了解问题的上下文。同时显示控制器代码,您的代码应该可以正常工作。尝试创建MCVE
.state("firstRes", {
cache: false,
url:'/firstRes',
views:{
content : {templateUrl: 'templates/firstRes.html',controller: 'mobileNumberCtrl'}
}
})
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp">
<table ng-controller="myCtrl" border="1">
<tr ng-repeat="x in accNum">
<td>{{x.ID}}</td>
</tr>
</table>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.accNum=[{"ID":"309001259753"},{"ID":"309000137788"}, {"ID":"309001335532"}]
});
</script>
</body>
</html>