为了账号安全,请及时绑定邮箱和手机立即绑定

请教关于angularJs的$watch 问题?

请教关于angularJs的$watch 问题?

嘛也不会 2016-10-05 15:59:39
angular.module("exampleApp",[])                 .directive("unorderedList",function(){                        return function(scope, element, attrs){                            var data= scope[attrs["unorderedList"]];                            var propertyExpression = attrs["listProperty"];                            if(angular.isArray(data)){                                var listElem = angular.element("<ul>");                                element.append(listElem);                                for(var i=0; i< data.length; i++){                                    (function(){                                        var itemElement =angular.element("<li>");                                        listElem.append(itemElement);                                        var index = i;                                        var watcherFn = function(watchScope){                                            return  watchScope.$eval(propertyExpression, data[index]);                                        }                                        scope.$watch(watcherFn, function(newValue,oldValue){                                            itemElement.text(newValue);                                        });                                    }())                                }                            }                        }                 })请问上述代码的执行过程具体是怎么执行的?
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 1746 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信