Angular ng-grid and JSON
Angular ng-grid and JSON
我对Angular很陌生,我正在尝试在ui网格表中显示我的JSON。无论如何,由于这类似于ng网格,我希望有人能帮助我。
我有一个类似的JSON:
{
Users: [
username:'blabla',
email:'bla@gmail.com',
type:'admin',
userId: [
id:'1222'
]
],
Teams: [
teamName: 'team1',
teamId: '123'
]
}
我想要的是:
$scope.gridOptions = {
data: myDataSource,
columnDefs: [{ field: 'Users.userName', displayName: 'userName', width: 90 }]
但是我无法访问所有的对象。只有当我将数据设置为myDataSource时,我才能访问用户名。Users
这是一个工作示例:http://jsfiddle.net/8jgpLn9h/
控制器:
var app = angular.module('app', ['ngTouch', 'ui.grid']);
app.controller('MainCtrl', ['$scope', function ($scope) {
$scope.data = {
Users : [{
username : 'titi',
email : 'bla@gmail.com',
type : 'admin',
userId : {
id : '1222'
}
},{
username : 'toto',
email : 'toto@gmail.com',
type : 'admin',
userId : {
id : '1'
}
}
],
Teams : {
teamName : 'team1',
teamId : '123'
}
};
$scope.gridOptions = { data: 'data.Users' };
}]);
HTML:
<div ng-app="app">
<div ng-controller="MainCtrl">
<div ui-grid="gridOptions" class="grid"></div>
</div>
</div>
相关文章:
- Ajax and Json with Rails
- JSON and jQuery Search
- JSON and javascript objects
- Remote json and Javascript
- JSON and javascript
- JSON and AJAX response
- JSON and Highcharts
- JSON and Angularjs
- Pupulate Dom HTML fom JSON and coffeescript
- JSON and AJAX with Python
- Securing JSON and ASP.NET MVC2
- Working with JSON and Angular NVD3
- json and null values
- Parsererror with json and PHP
- RIA Services JSON and Ext.Js
- JSON and Python
- Laravel 3 JSON and jQuery getJSON
- json and javascript issue
- JSON and Angular
- flickr api, json and set list