过滤器ng -重复结果与变量在JQuery中找到

Filter Ng-Repeat Results with Variable Found in JQuery

本文关键字:JQuery 变量 ng -重 结果 过滤器      更新时间:2023-09-26

我有使用AngularJs的ng-repeat显示的数据,不幸的是,我还没有在AngularJs中找到一种可靠的方式来主动侦听窗口中的变化。位置和响应,但我已经在Jquery中这样做了。我想从我的Jquery函数中获得结果,并使用参数过滤ng-repeat结果。下面是一个angular的例子:

<div  id="center" class="datagrid">
            <table>
              <thead>
                <tr>
                  <th> ID </th>
                  <th> Phone </th>
                  <th> Address </th>
                  <th> Zip </th>
                </tr>
              </thead>
              <tbody>
                <tr ng-repeat="client in clients | orderBy:'id' | filter:{id:clientId} | limitTo: 1 track by $index">
    <td>
     {{client.id}}
  </td>
  <td>
     <div class="form-group">
     <input class="form-control" ng-model="updateform.phone" name="phone" ng-init="updateform.phone=client.phone" type="text "/>
     </div>
    </td>
  <td>
  <div class="form-group">
     <input class="form-control" ng-model="updateform.address" name="address" ng-init="updateform.address = client.address" type="text "/>
    </div>
    </td>
  <td>
  <div class="form-group">
     <input class="form-control" ng-model="updateform.zip" name="zip" ng-init="updateform.zip = client.zip" type="text "/>
     </div>
    </td>
 </tr>
 </tbody>

JQuery函数:

    $(window).on('hashchange', function() {
     var id = document.location.href.split('about#/')[1];
     console.log(id)
});

如果您正在使用routeProvider服务,您可以这样做:

$rootScope.$on('$locationChangeSuccess', function(event){
     var url = $location.url(),
})