I don’t know if my method is suitable. I use ui-router for routing. First, I will enter a general URL, and then click the category link in left.html to refresh the product details in right.html, because what I do is In the micro mall, the product categories are placed on the left and the specific item list is on the right. Based on the query of clicking on the product category on the left, The problem is that when entering this route from the previous page, ng-repeat will first loop and display a bunch of original content without data, including {{item.list}} Such a thing will then replace the requested data. How to solve it?
In addition, is there any way to request background data and load it to the front page when entering a page? Currently, the data bound to $rootScope is used...it feels low...
I don’t know if I have explained it clearly. I am new to angularjs. Please give me some advice~~
<section>
<p ui-view="left"></p>
<p ui-view="right"></p>
</section>
left.html
<p ng-repeat="item in items">
{{item.list}}//循环输出商品种类,期望点击某一种类然后刷新加载右侧right.html中的商品明细列表,包括商品名称,图片地址,单价之类的。
</p>
<p ng-repeat="item in items">
{{item.goodsName}}//具体商品信息...
</p>
大家讲道理2017-05-15 16:57:51
Use ng-include
就可以做一个你需求的页面,不需要什么ui-router
. Of course, if your business is more complex, that’s fine too. The usage is similar. I’ll give you a demo as a reference:
plunker
What you mentionedng-repeat会先循环显示一堆没有数据的原始内容,包括{{item.list}}这样的东西,然后才会替换出现请求得到的数据,请问该怎样解决呢?
,用ng-cloak
can be solved, see the document: ngCloak