0
<body>
<div ng-app="myapp"ng-model="user"ng-init="user=[{'name':'A','email':'[email protected]','mobile':'9494563132','city':'banglore'},
{'name':'B','email':'[email protected]','mobile':'9494563132','city':'pune'},
{'name':'C','email':'[email protected]','mobile':'9494563132','city':'hyderebad'}] "ng-init="fuser='hello'">
<div ng-controller="myctrl" >
<table align="left">
<tr>
<td><ul>
<h1>City</h1>
<li ng-repeat="x in user">{{x.city}}</li>
</ul></td>
</tr>
</table>
<table align="center">
<tr>
<th>Select User</th>
<td>
<select ng-model="u" ng-change="getuser(name,email,mobile,city)">
<option value="">Choose name</option>
<option ng-repeat="x in user" value="{{x.name}}">{{x.name}}</option>
</select></td>
</tr>
<tr>
<table align="center" cellpadding="5" ng-model="table" bgcolor='skyblue'>
<caption><h2>User info</h2></caption>
<tr>
<th>Name</th>
<th>email</th>
<th>mobile</th>
<th>city</th>
</tr>
<tr ng-repeat="row in user|filter:fuser">
<td>{{row.name}}</td>
<td>{{row.email}}</td>
<td>{{row.mobile}}</td>
<td>{{row.city}}</td>
</tr>
</table>
<tr>
</table>
</div>
</div>
<script>
var obj = angular.module("myapp",[]);
obj.controller("myctrl",function($scope)
{
$scope.u=this.response;}
$scope.getuser=function(uname)
{
$scope.fuser=uname;
}
});
請幫幫我從數組中的數據提取到表通過使用下拉選項過濾數據和diplay所述定義的多維數組的數據傳遞到控制器相關data.i不能使用$ http事件,我不想在控制器初始化我的陣列如何從視圖中angularjs通過使用納克-INIT鑑於
謝謝大家的響應SAE,有沒有可能通過定義在我想知道的觀點@SaE – swapnika
的NG-初始化指令陣列爲什麼你想從視圖中提取它從視圖中即提取數據,?從哪裏可以得到這些數據? – 2017-04-03 11:42:44