{"id":208768,"date":"2014-01-12T01:48:03","date_gmt":"2014-01-11T21:48:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=208768"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=208768","title":{"rendered":"<span class=\"post_title\">\u0418\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 $watch&#8217;\u0435\u0440\u043e\u0432<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0425\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u043e\u0439 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 $digest() \u043f\u0443\u0442\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u044b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 $watch.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u043c\u044b\u0441\u043b \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u043e \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043d\u0438\u0442\u044c \u0431\u0438\u043d\u0434\u0438\u043d\u0433 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"html\">&lt;h1 ng-bind=&quot;l10n.main_title&quot;&gt;&lt;\/h1&gt; <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;a ng-href=&quot;\/edit\/{{user.id}}&quot; ng-bind=&quot;user.name&quot;&gt;&lt;\/a&gt; <\/code><\/pre>\n<p>  \u042d\u0442\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043b\u044e\u0431\u0435\u0437\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c $digest. \u0418\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0442\u0435\u043a\u0441\u0442\u0430:<\/p>\n<pre><code class=\"javascript\">app.directive(staticText', function() {     return {       restrict: &quot;A&quot;       link: function(scope, element, attrs) {         element.text(scope.$eval(attrs.customText));       }     };   }) <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;h1 custom-text=&quot;l10n.main_title&quot;&gt;&lt;\/h1&gt; <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 \u043c\u0438\u043d\u0443\u0441 \u043e\u0434\u0438\u043d $watch.<br \/>  \u0412\u044b\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043d\u0430 GitHub \u043b\u0435\u0436\u0430\u0442 \u0434\u0432\u0430 \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u044f:  <\/p>\n<ul>\n<li><b>$watch fighters<\/b> \u2014 <a href=\"https:\/\/github.com\/abourget\/abourget-angular\">GitHub<\/a><\/li>\n<li><b>Bindonce<\/b> \u2014 <a href=\"https:\/\/github.com\/Pasvaz\/bindonce\">GitHub<\/a><\/li>\n<\/ul>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 ($watch fighters) \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0442\u0430\u043a\u0438\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b:  <\/p>\n<ul>\n<li>set-title<\/li>\n<li>set-href<\/li>\n<li>set-text<\/li>\n<li>set-html<\/li>\n<li>set-class<\/li>\n<li>set-if<\/li>\n<\/ul>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u0436\u0435 (Bindonce) \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u0442.\u043a. \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043d\u0438 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f ajax-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c). \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"html\">&lt;div bindonce=&quot;User&quot;&gt; &lt;h1 bo-text=&quot;User.name&quot;&gt;&lt;\/h1&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <b>bindonce<\/b> \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u043c\u0435\u043d\u044b\u0439 $watch, \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0439 \u0432 \u043d\u0435\u0451 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0442 <i>undefined<\/i> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 bo-* \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b, \u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 $watch \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f.<br \/>  \u041c\u043e\u0434\u0443\u043b\u044c <b>Bindonce<\/b> \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442:  <\/p>\n<ul>\n<li>bo-if<\/li>\n<li>bo-show<\/li>\n<li>bo-hide<\/li>\n<li>bo-text<\/li>\n<li>bo-html<\/li>\n<li>bo-href<\/li>\n<li>bo-src<\/li>\n<li>bo-class<\/li>\n<li>bo-alt<\/li>\n<li>bo-title<\/li>\n<li>bo-id<\/li>\n<li>bo-style<\/li>\n<li>bo-value<\/li>\n<li>bo-attr bo-attr-foo<\/li>\n<\/ul>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 <a href=\"https:\/\/github.com\/Pasvaz\/bindonce\">\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a>, \u0442\u0430\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044b\u0439 readme.<\/p>\n<p>  \u041d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0430\u0448\u0435\u043b <a href=\"http:\/\/stackoverflow.com\/questions\/18499909\/how-to-count-total-number-of-watches-on-a-page\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041e\u043d\u0430 <s>\u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e<\/s> \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e $watch&#8217;\u0435\u0440\u043e\u0432 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. <\/p>\n<pre><code class=\"javascript\">(function () {      var root = $(document.getElementsByTagName('body'));     var watchers = [];      var f = function (element) {         if (element.data().hasOwnProperty('$scope')) {             angular.forEach(element.data().$scope.$$watchers, function (watcher) {                 watchers.push(watcher);             });         }          angular.forEach(element.children(), function (childElement) {             f($(childElement));         });     };      f(root);      console.log(watchers.length); })(); <\/code><\/pre>\n<p>  \u0420\u0430\u0434\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e \u0438 \u043f\u043e\u043b\u0435 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f zero-watch \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432.<br \/>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043a\u043e\u043c\u0443 \u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0421\u043f\u0430\u0441\u0438\u0431\u043e.    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/208768\/\"> http:\/\/habrahabr.ru\/post\/208768\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0425\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u043e\u0439 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 $digest() \u043f\u0443\u0442\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u044b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 $watch.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-208768","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/208768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=208768"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/208768\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=208768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=208768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=208768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}