如何获得数组的值和使用猫鼬结构化? [英] How to get the array value and in structurized using Mongoose?

查看:82
本文介绍了如何获得数组的值和使用猫鼬结构化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 MeanStack AngularJS .我像这样将值存储到MongoDB中:

I am using MeanStack AngularJS. I stored the values into MongoDB like this:

"RoleName" : "Verify",    
"IsActive" : true,
"UIList" : 
    {
        "UiName": "One",
        "View" : false,
        "Edit" : false
    },
    {
       "UiName": "Two",
        "View" : false,
        "Edit" : false
    },
    {
        "UiName": "Three",
        "View" : false,
        "Edit" : false
    },
    {
        "UiName": "Four",
        "View" : false,
        "Edit" : false
    },
    {
        "UiName": "Five",
        "View" : false,
        "Edit" : false
    }

Contoller

$http.get('/Manage_Datashow').success(function (response) {
    $scope.Manage_Roleser = response;
});

服务器

app.get('/Manage_Datashow', function (req, res) {
    db.New_Role.find(function (err, docs) {
        console.log(docs);
        res.json(docs);
    });
});

在此附上示例代码.我想使用ng-repeat绑定列表中的值.

Here I attached my sample code. I want to bind the values in list using ng-repeat.

我的代码:

<ul ng-repeat=Manage_Rolese in Manage_Roleser >
  <li>{{Manage_Rolese.UIList.UiName}}</li>
  <li>{{Manage_Rolese.UIList.View}}</li>
  <li>{{Manage_Rolese.UIList.Edit}}</li>
</ul>

示例:

我需要这样的输出.

推荐答案

尝试一下

<html>
<body>
	<div Class="container" ng-app="myapp" ng-controller="namesctrl">
		
		<table>
			<thead>
				<th>
					UiName
				</th>
				<th>
					View
				</th>
				<th>
					Edit
				</th>
			</thead>
			<tr ng-repeat="mgr in Manage_Roleser.UIList">
				<td>
					{{mgr.UiName}}
				</td>
				<td>
				|{{mgr.View}}
				</td>
				<td>
					{{mgr.View}}
				</td>
			</tr>
		</table>
	</div>  


	<script Src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js"></script>

	<script>
		var app=angular.module("myapp", []);
		app.controller("namesctrl", function($scope){

			$scope.Manage_Roleser= 
			{
				"RoleName" : "Verify",    
    			"IsActive" : true,
				"UIList": [{
				"UiName": "One",
				"View" : false,
				"Edit" : false
			},{
				"UiName": "Two",
				"View" : false,
				"Edit" : false
			},
			{
				"UiName": "Three",
				"View" : false,
				"Edit" : false
			},
			{
				"UiName": "Four",
				"View" : false,
				"Edit" : false
			},
			{
				"UiName": "Five",
				"View" : false,
				"Edit" : false
			}]
		}
			

		});



	</script>
</body>
</html>

这篇关于如何获得数组的值和使用猫鼬结构化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆