【发布时间】:2014-10-26 22:06:48
【问题描述】:
我的指令包含一个 javascript 对象。我尝试使用 jquery 查找绑定到此 javascript 对象的所有 html 元素。 jquery如何获取angularjs对象的绑定数据?
也许上面的代码更好地解释了我的计划。
angular.module('app').directive('highlight', [
'$rootScope', '$compile', function ($rootScope, $compile) {
return {
replace: true,
templateUrl: 'highlight.html',
link: function (scope, element, attrs) {
//this data object do we need to highlight
scope.Tohighlight;
$($.find('input, select')).each(function () {
//todo extract data if input or selection are binding data
//<input type="x" data-ng-model="data" /></span>
var data = angular.extractDataFromhtmlelement($(this));
//if html element contains our data add some css stuff
if(data == scope.Tohighlight)
{
}
});
};
}
]);
我不知道是否存在用于我的目的的 angularjs 方法。如何获取 jquery 对象的绑定 angularjs 数据模型?谢谢。
【问题讨论】:
-
我已经更新了我的答案stackoverflow.com/a/26578630/947687。对你有帮助吗?
标签: javascript jquery angularjs angularjs-directive