jquery与angular的交互
HTML:
<table class="table table-striped" ng-app="myApp"> <tr> <th>时间</th> <th>教练员</th> <th>学员</th> <th>车牌号</th> <th>SIM</th> <th>经度</th> <th>纬度</th> <th>方向</th> <th>速度(km/h)</th> <th>操作</th> </tr> <tr ng-controller="myCtrl"> <td>{{obj.gpsTime}}</td> <td>{{obj.coachName}}</td> <td>{{obj.studentName}}</td> <td>{{obj.licnum}}</td> <td>{{obj.sim}}</td> <td>{{obj.lng}}</td> <td>{{obj.lat}}</td> <td>{{obj.direct}}</td> <td>{{obj.speed}}</td> <td><a title="立即拍照" href="#" class="ljpz"><i class="fa fa-camera"></i></a></td> </tr> </table>
JS:
1. angular(不能放在jquery的onready事件中)
var app = angular.module(‘myApp‘, []); app.controller(‘myCtrl‘, function($scope) { $scope.obj = { gpsTime : ‘‘, coachName : ‘‘, studentName : ‘‘, licnum : ‘‘, sim : ‘‘, lng : ‘‘, lat : ‘‘, direct : ‘‘, speed : ‘‘ }; });
2.jquer
y(可以放在一个函数或ready事件中)
var scope = $(‘tr[ng-controller="myCtrl"]‘).scope();// 获得angular的作用域 scope.obj.coachName = ‘hi‘; scope.$apply();// 绑定到视图
相关推荐
QiaoranC 2020-09-25
颤抖吧腿子 2020-09-04
liduote 2020-06-16
阿斌Elements 2020-06-11
xxuncle 2020-06-05
ChinaGuanq 2020-06-05
wanghongsha 2020-03-26
csm0 2020-03-05
shyoushine 2020-02-25
electronvolt 2020-02-12
jsonwoo 2020-01-20
ZadarrienChina 2020-01-07
wwwxuewen 2020-01-04
dynsxyc 2020-01-03
liangjielaoshi 2019-12-27
bowean 2019-12-27
wwwxuewen 2019-12-25
liwusen 2019-12-16
颤抖吧腿子 2019-12-16