本文介绍了带有angularjs的Mvc - 嵌套转发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我们必须在asp.net mvc中使用angularjs实现嵌套的ng-repeat,而代码我们已经使用了它不能正常工作。 
我们想要分组基于内容类别的产品列表。请尽快帮助。下面的代码我们使用

预期输出:
类别1
产品1 catg1
产品2 catg1

类别2
产品1 catg2
Product2 catg2
 





我有什么试过:



 index.cshtml文件:

< div data-ng-repeat = 分类中的catg>
{{catg.ecom_category_title}}
< ul data-ng-repeat =产品中的prd>
< li> {{prd.ecom_product_title}}< / li>
< / ul>
< / div>

category.js文件:

$ http.get('/ api / Category / ListAllCategory',{params:{}})。success(function(data){
$ scope.Categorys = data;
for(var i = 0; i< $ scope.Categorys.length; i ++){
$ scope.getCategoryID = $ scope.Categorys [i ] .ecom_category_id;
$ http.get('/ api / Product / ListAllProductByCategory',{params:{ecom_category_id:$ scope.getCategoryID}})。success(function(response){
alert(' dsfsdf');
$ scope.Products = response;
})
.error(function(){
$ scope.error =Some Error。;
});
}

})
.error(function(){
$ scope.error =Some Error。;
} );
解决方案



scope.Categorys.length; i ++){


we have to implement nested ng-repeat in asp.net mvc with angularjs below code we have used its not working.
we want grouping content category based product listing. please anyone help ASAP. Below code we have used

Expected output:
Category1
	Product1 catg1
	Product2 catg1

Category2
	Product1 catg2
	Product2 catg2



What I have tried:

index.cshtml file:

<div data-ng-repeat="catg in Categorys">
{{catg.ecom_category_title}}
<ul data-ng-repeat="prd in Products">
    <li>{{prd.ecom_product_title}}</li>
</ul>
</div>

category.js file:

$http.get('/api/Category/ListAllCategory', { params: {} }).success(function (data) {
    $scope.Categorys = data;
    for (var i = 0; i < $scope.Categorys.length; i++) {
        $scope.getCategoryID = $scope.Categorys[i].ecom_category_id;
        $http.get('/api/Product/ListAllProductByCategory', { params: { ecom_category_id: $scope.getCategoryID } }).success(function (response) {
            alert('dsfsdf');
            $scope.Products = response;
        })
       .error(function () {
           $scope.error = "Some Error.";
       });
    }

})
.error(function () {
    $scope.error = "Some Error.";
});
解决方案




这篇关于带有angularjs的Mvc - 嵌套转发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 03:54