$ apply,$ watch和$ digest控制器特定或模块特定?

时间:2016-03-30 14:37:27

标签: angularjs angularjs-scope

我想知道的是当我在一个特定的控制器中调用say $ scope。$ apply时,所有其他控制器中的所有范围变量都在给定的角度应用程序模块中具有当前活动视图,或者只刷新范围变量那特定的控制器?

1 个答案:

答案 0 :(得分:2)

查看source code

.children()

function update(username, row) { affiliation_val = $(document.getElementsByName('affiliation')).val(), comments_val = $(document.getElementsByName('comments')).val(), role_val = $(document.getElementsByName('role')).val(); //the search above does not work when I add multiple inputs… it returns only the first three inputs console.log( $(row).closest(“input”) ); //one of my attempts... I also did using a combination of parents("tbody") and children("input"), for example... and many others } function format(d) { var message1 = '<table cellpadding="8" cellspacing="0" border="0" style="padding-left:50px;">'+ '<tr>'+ '<td class="text-right"><b>User ID:</b></td>'+ '<td class="text-left"> &nbsp; '+username+'</td>'+ '</tr>'+ '<tr>'+ '<td class="text-right"><b>Password last set:</b></td>'+ '<td class="text-left"> &nbsp; '+d.pwd_last_set+'</td>'+ '</tr>'+ '<tr>'+ '<td class="text-right"><b>Uid number:</b></td>'+ '<td class="text-left"> &nbsp; '+d.uid+'</td>'+ '</tr>'+ '<tr>'+ '<td class="text-right"><b>Email:</b></td>'+ '<td class="text-left"> &nbsp; '+d.email+'</td>'+ '</tr>'+ split_projects(d.projects_name, d.projects_role), message2 = '<tr>'+ '<td class="text-right"><b>Affiliation:</b></td>'+ '<td class="text-left"><input type="text" name="affiliation" value="'+d.affiliation+'" '+readonly+' /></td>'+ '</tr>'+ '<tr>'+ '<td class="text-right"><b>Comments:</b></td>'+ '<td class="text-left"> <input type="text" name="comments" value="'+d.comment+'" '+readonly+' /></td>'+ '</tr>'+ '<tr>'+ '<td class="text-right"><b>Role:</b></td>'+ '<td class="text-left"><input type="text" name="role" value="'+d.role+'" '+readonly+' /></td>'+ '</tr>', message3 = show_inconsistency(inconsistent)+ show_miss_uid(miss_uid)+ '<tr>'+ '<td>&nbsp; </td>' + '<td>'+ '<button type="button" class="btn btn-default" onclick="sendMail(\'' +username+ '\'); return false">' + '<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span> Request change of permission' + '</button> <br/><br/> ' + '</td>' + '</tr>' + '</table>', button = '<tr><td>&nbsp;</td><td><button class="btn btn-default" onclick="update(\''+username+'\', this)">Update</button</td></tr>'; return message1+message2+button+message3; } 功能会在 $apply: function(expr) { try { beginPhase('$apply'); try { return this.$eval(expr); } finally { clearPhase(); } } catch (e) { $exceptionHandler(e); } finally { try { $rootScope.$digest(); } catch (e) { $exceptionHandler(e); throw e; } } }, 上触发$apply。这意味着整个应用程序的所有监视功能都会得到评估。