java隨記

          堅持就是勝利!

           

          js外部調(diào)用更新angularjs的ng-repeat視圖問題

          找了個開源基礎(chǔ)框架測試一下微信公眾號。沒想是用jquery做的restful風(fēng)格的頁面。jquery更
          新table中數(shù)據(jù)就有些麻煩。所以用angularjs重構(gòu)一下。
          頁面中angularjs展示數(shù)據(jù)  
          <body   ng-controller="multi"> 
            <table id="baseTable" class="table table-striped table-bordered table-hover" >
          <thead>
          <tr><th style="width:10%" class="center">標(biāo)題</th>
          </tr>
          </thead>
                         <body   ng-controller="multi">   
                          <tbody>  
                                   <tr ng-repeat="item in defaultData " >
                                       <td class='center hidden-480'>{{item.title}}</td>    
                         </tr> 
            </tbody>
                      </body>
            </table>
          </body>
          外部jquery的ajax調(diào)用更新數(shù)據(jù) 
                              var controllerScope = $('body[ng-controller="multi"]').scope();
                      controllerScope.defaultData=results;
                      controllerScope.$apply();
                    
          注意:外部js不要刪除了下面這段代碼塊。
                                  <tr ng-repeat="item in defaultData " >
                                       <td class='center hidden-480'>{{item.title}}</td>    
                           </tr> 

          posted on 2017-09-11 21:37 傻 瓜 閱讀(762) 評論(0)  編輯  收藏 所屬分類: Ajax 、javascript

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(7)

          我參與的團隊

          隨筆分類

          隨筆檔案

          文章分類

          友情鏈接

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 交口县| 闽清县| 马关县| 蕉岭县| 乌什县| 亳州市| 中阳县| 汾阳市| 乐都县| 湟中县| 龙门县| 宿州市| 喀喇| 永仁县| 常山县| 桃园县| 商水县| 凤城市| 修武县| 碌曲县| 侯马市| 谷城县| 武宣县| 新河县| 大城县| 六安市| 肥西县| 汝城县| 钟山县| 安塞县| 宜良县| 班戈县| 雅安市| 祥云县| 册亨县| 那坡县| 安溪县| 台中县| 建始县| 翁牛特旗| 景宁|