{"id":225891,"date":"2014-06-10T18:16:03","date_gmt":"2014-06-10T14:16:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=225891"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=225891","title":{"rendered":"<span class=\"post_title\">AngularJS \u2014 \u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 ng-if?<\/span>"},"content":{"rendered":"<div class=\"content html_format\">     \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/4ff\/67a\/63c\/4ff67a63c23b9df0e2f9ec8a850b1822.jpg\" align=\"right\"\/><br \/>  \u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u044f \u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b <a href=\"http:\/\/habrahabr.ru\/post\/225243\/\">\u043f\u0440\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 ng-if \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b<\/a>, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. <\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u0430\u043a tooltip, popover, modal windows \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0414\u0443\u043c\u0430\u044e, \u0432\u0441\u0435 \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e \u043d\u0438\u0445 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443. \u0414\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u0437 \u043d\u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b, \u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u2014 \u0432\u0441\u0435 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043a\u043d\u0430 \u043b\u0435\u0436\u0430\u043b\u0438 \u0431\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 body \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0431\u044b \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e. \u041d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u0432\u0441\u0435 \u044d\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u043a\u0430\u043a \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0443 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0441 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<pre><code class=\"html\">&lt;div style=&quot;position: relative; overflow:hidden&quot;&gt;   &lt;button ng-click=&quot;visible = true&quot;&gt;Greeting&lt;\/button&gt;    &lt;modal visible=&quot;visible&quot;&gt;       Hello, Habr!   &lt;\/modal&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u041c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043a\u043d\u0430 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. <br \/>  \u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u2014 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b:<\/p>\n<pre><code class=\"javascript\">module.directive('modal',[ \t\t'$rootElement', \tfunction( \t\t$rootElement \t){ \t\treturn { \t\t\trestrict: 'E', \t\t\t... \t\t\tlink: function(scope, element){ \t\t\t\telement.appendTo($rootElement);  \t\t\t\tscope.$on('$destroy', function(){ \t\t\t\t\telement.remove(); \t\t\t\t});                  ... \t\t\t} \t\t} \t}] }); <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u0432\u044b\u0434\u0435\u0440\u0430\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0440\u0443\u0442\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. \u0412\u0441\u0435 \u0432\u0440\u043e\u0434\u0435 \u041e\u041a, \u043d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0432 \u043f\u0430\u0440\u0435 \u0441 \u0442\u0430\u043a\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>ng-if<\/code> \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430.<\/p>\n<p>  <code>ng-if <\/code> \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0434\u0430\u043b\u044f\u0435\u0442 DOM \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u044d\u0442\u043e \u044f \u0434\u0443\u043c\u0430\u044e \u043c\u043d\u043e\u0433\u0438\u0435 \u0437\u043d\u0430\u044e\u0442, \u043d\u043e \u043d\u0435 \u043c\u043d\u043e\u0433\u0438\u0435 \u0437\u043d\u0430\u044e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<p>  <a href=\"https:\/\/github.com\/angular\/angular.js\/blob\/d3c50c845671f0f8bcc3f7842df9e2fb1d1b1c40\/src\/ng\/directive\/ngIf.js#L88\">\u0412\u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c watcher<\/a> <code>ng-if<\/code> \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430.<br \/>  \u041f\u0440\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 <code>document.createComment(' end ngIf: ' + $attr.ngIf + ' ');<\/code> \u0438 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>block.clone<\/code> \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:  <\/p>\n<ul>\n<li>0 \u2014 \u0441\u0430\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u044b\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 <code>ng-if<\/code> \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430<\/li>\n<li>1 \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439<\/li>\n<\/ul>\n<p>  \u0412 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432\u044b \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0447\u0430\u0441\u0442\u043e \u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/76b\/90e\/686\/76b90e686070fda7d98ee1710df34830.png\"\/><\/p>\n<blockquote><p>\u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 \u2014 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>ng-if=&quot;!task.id&quot;<\/code> \u2014 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 li, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 \u0435\u0441\u0442\u044c \u0432 DOM \u0434\u0435\u0440\u0435\u0432\u0435 \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438 <code>&lt;!-- ngIf: !task.id --&gt;<\/code> \u0438 <code>&lt;!-- end ngIf: !task.id --&gt;<\/code>. \u0412\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>ng-if=&quot;validation.task.app_id&quot;<\/code> \u2014 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438 \u043d\u0435\u0442\u0443 \u043d\u0438\u0447\u0435\u0433\u043e. <\/p><\/blockquote>\n<p>  \u041f\u0440\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u2014 destroy \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e scope \u0438 <a href=\"https:\/\/github.com\/angular\/angular.js\/blob\/d3c50c845671f0f8bcc3f7842df9e2fb1d1b1c40\/src\/ng\/directive\/ngIf.js#L114\"> \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/a>. \u0418 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/angular\/angular.js\/blob\/d3c50c845671f0f8bcc3f7842df9e2fb1d1b1c40\/src\/Angular.js#L1562\">getBlockElements<\/a>:  <\/p>\n<pre><code class=\"javascript\">\/**  * Return the DOM siblings between the first and last node in the given array.  * @param {Array} array like object  * @returns {DOMElement} object containing the elements  *\/ function getBlockElements(nodes) {   var startNode = nodes[0],       endNode = nodes[nodes.length - 1];   if (startNode === endNode) {     return jqLite(startNode);   }    var element = startNode;   var elements = [element];    do {     element = element.nextSibling;     if (!element) break;     elements.push(element);   } while (element !== endNode);    return jqLite(elements); } <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u0435\u0451 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u2014 <i>Return the DOM siblings between the first and last node in the given array.<\/i><br \/>  \u0410 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 nodes \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u0432\u0430\u0448\u0435. \u0422\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0435\u0442 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0435\u0436\u0434\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u044b\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 <code>ng-if<\/code> \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c <code>&lt;!-- eng ngIf: .... --&gt;<\/code>, \u0430 \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043d\u0435 \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u2014 \u0442\u043e \u0432\u0435\u0440\u043d\u0435\u0442 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u043e\u0441\u043b\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e.<\/p>\n<p>  \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0442\u0430\u043a\u043e\u0439 \u0442\u0435\u043c\u043f\u043b\u0435\u0439\u0442 (#angular-application \u2014 \u0440\u0443\u0442\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f):  <\/p>\n<pre><code class=\"html\">&lt;div id=&quot;angular-application&quot;&gt; \t... \t \t&lt;div style=&quot;position: relative; overflow: hidden&quot;&gt; \t\t&lt;div style=&quot;position: absolute; right: 0; bottom: 0&quot;&gt; \t\t\t&lt;modal ng-if=&quot;isFirstModal()&quot; id=&quot;modal-1&quot;&gt;...&lt;\/modal&gt; \t\t\t&lt;modal ng-if=&quot;isSecondModal()&quot; id=&quot;modal-2&quot;&gt;...&lt;\/modal&gt; \t\t&lt;\/div&gt; \t\t&lt;div style=&quot;position: absolute; left: 0; bottom: 0&quot;&gt; \t\t\t&lt;popover ng-if=&quot;isFirstPopover()&quot; id=&quot;popover-1&quot;&gt;...&lt;\/popover&gt; \t\t\t&lt;popover ng-if=&quot;isSecondPopover()&quot; id=&quot;popover-2&quot;&gt;...&lt;\/popover&gt; \t\t&lt;\/div&gt; \t&lt;\/div&gt;\t  \t... &lt;\/div&gt; <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0442\u0441\u044f \u0432 \u0442\u0430\u043a\u043e\u0439 html:<\/p>\n<pre><code class=\"html\">&lt;div id=&quot;angular-application&quot;&gt; \t... \t \t&lt;div style=&quot;position: relative; overflow: hidden&quot;&gt; \t\t&lt;div style=&quot;position: absolute; right: 0; bottom: 0&quot;&gt; \t\t\t&lt;!-- ngIf: isFirstModal() --&gt; \t\t\t&lt;!-- end ngIf: isFirstModal() --&gt; \t\t\t&lt;!-- ngIf: isSecondModal() --&gt; \t\t\t&lt;!-- end ngIf: isSecondModal() --&gt; \t\t&lt;\/div&gt; \t\t&lt;div style=&quot;position: absolute; left: 0; bottom: 0&quot;&gt; \t\t\t&lt;!-- ngIf: isFirstPopover() --&gt; \t\t\t&lt;!-- end ngIf: isFirstPopover() --&gt; \t\t\t&lt;!-- ngIf: isSecondPopover() --&gt; \t\t\t&lt;!-- end ngIf: isSecondPopover() --&gt; \t\t&lt;\/div&gt; \t&lt;\/div&gt;\t  \t...  \t&lt;div id=&quot;popover-1&quot; class=&quot;popover&quot;&gt;...&lt;\/div&gt; \t&lt;div id=&quot;modal-1&quot; class=&quot;modal-window&quot;&gt;...&lt;\/div&gt; \t&lt;div id=&quot;modal-2&quot; class=&quot;modal-window&quot;&gt;...&lt;\/div&gt; \t&lt;div id=&quot;popover-2&quot; class=&quot;popover&quot;&gt;...&lt;\/div&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435 \u2014 \u0432\u0441\u0435 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043a\u043d\u0430 \u0438 \u043f\u043e\u043f\u043e\u0432\u0435\u0440\u044b, \u0447\u0442\u043e \u0431\u044b \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0438\u0445 \u0432\u0435\u0440\u0441\u0442\u043a\u0430 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u043f\u0440\u0435\u0436\u043d\u0435\u043c \u043c\u0435\u0441\u0442\u0435. \u0418 \u0442\u0435\u043f\u0435\u0440\u044c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/github.com\/angular\/angular.js\/blob\/d3c50c845671f0f8bcc3f7842df9e2fb1d1b1c40\/src\/Angular.js#L1562\">getBlockElements<\/a> \u0434\u043b\u044f <code>&lt;popover ng-if=&quot;isFirstPopover()&quot; id=&quot;popover-1&quot;&gt;.<\/code> \u2014 <a href=\"https:\/\/github.com\/angular\/angular.js\/blob\/d9b90d7c10a8e1bacbee0aeb7e86093cca9e8ed2\/src\/Angular.js#L1579\">\u0432\u0435\u0440\u043d\u0435\u0442 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b<\/a> \u2014 <b>#popover-1<\/b>,<b>#modal-1<\/b>, <b>#modal-2<\/b>, <b>#popover-2<\/b>. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f <code>ng-if=&quot;isFirstPopover()&quot; <\/code> <u>\u0438\u0437 DOM \u0434\u0435\u0440\u0435\u0432\u0430 \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u0432\u0441\u0435 \u044d\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b<\/u>. <\/p>\n<p>  \u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\u041d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a \ud83d\ude42 \u041d\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b. \u041d\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0443 \u043d\u0430\u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0435\u0441\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043e\u0434\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439, \u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043a\u043d\u043e\u043f\u043a\u0443, \u043f\u043e\u043f\u043e\u0432\u0435\u0440, \u0438 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e. \u0418 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u2014 \u0432\u0435\u0440\u0441\u0442\u043a\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f, \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u2014 \u0442\u043e\u0436\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435 \u0432\u0435\u0440\u043d\u044b\u043c.<\/li>\n<li>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u043d\u0443\u0436\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u0422\u043e\u0436\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043c\u0435\u043d\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u0442\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043d\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442.<\/li>\n<li>\u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ng-if \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445. \u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043c\u044b \u0438 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0438. \u0427\u0443\u0442\u044c \u0447\u0443\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438 \u043a\u043e\u0434, \u043d\u043e \u0437\u0430\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/li>\n<li>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u044b \u0434\u043b\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432. <a href=\"https:\/\/docs.angularjs.org\/api\/ng\/service\/$compile#-priority-\">\u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442<\/a> \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u0448\u0435, \u0447\u0435\u043c \u0443 <code>ng-if<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u044b\u0448\u0435 600.<\/li>\n<li>\u041f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u043d\u0435 \u0440\u0443\u0442\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b, \u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u044b\u0439. \u0422\u043e \u0435\u0441\u0442\u044c: <code>element.find('[append-to-root]').appendTo($rootElement);<\/code> <\/li>\n<li> \u041d\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>ng-if<\/code> \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443, \u0430 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0435\u0451: <br \/> \n<pre><code class=\"html\">&lt;div ng-if=&quot;condition&quot;&gt;   &lt;my-custom-directive&gt;...&lt;\/my-custom-directive&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>   <\/li>\n<\/ul>\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\/225891\/\"> http:\/\/habrahabr.ru\/post\/225891\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">     \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/4ff\/67a\/63c\/4ff67a63c23b9df0e2f9ec8a850b1822.jpg\" align=\"right\"\/><br \/>  \u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u044f \u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b <a href=\"http:\/\/habrahabr.ru\/post\/225243\/\">\u043f\u0440\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 ng-if \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b<\/a>, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. <\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u0430\u043a tooltip, popover, modal windows \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0414\u0443\u043c\u0430\u044e, \u0432\u0441\u0435 \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e \u043d\u0438\u0445 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443. \u0414\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u0437 \u043d\u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b, \u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u2014 \u0432\u0441\u0435 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043a\u043d\u0430 \u043b\u0435\u0436\u0430\u043b\u0438 \u0431\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 body \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0431\u044b \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e. \u041d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u0432\u0441\u0435 \u044d\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u043a\u0430\u043a \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0443 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0441 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<pre><code class=\"html\">&lt;div style=&quot;position: relative; overflow:hidden&quot;&gt;   &lt;button ng-click=&quot;visible = true&quot;&gt;Greeting&lt;\/button&gt;    &lt;modal visible=&quot;visible&quot;&gt;       Hello, Habr!   &lt;\/modal&gt; &lt;\/div&gt; <\/code><\/pre>\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-225891","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/225891","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=225891"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/225891\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=225891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=225891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=225891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}