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C,CAAC,CAAC;AAmDrD","file":"angular2/src/directives/if.es6","sourcesContent":["import {Viewport} from 'angular2/src/core/annotations/annotations';\nimport {ViewContainer} from 'angular2/src/core/compiler/view_container';\nimport {isBlank} from 'angular2/src/facade/lang';\n\n/**\n * Removes or recreates a portion of the DOM tree based on an {expression}.\n *\n * If the expression assigned to `if` evaluates to a false value then the element is removed from the\n * DOM, otherwise a clone of the element is reinserted into the DOM.\n *\n * # Example:\n *\n * ```\n * <div *if=\"errorCount > 0\" class=\"error\">\n * <!-- Error message displayed when the errorCount property on the current context is greater than 0. -->\n * {{errorCount}} errors detected\n * </div>\n * ```\n *\n * # Syntax\n *\n * - `<div *if=\"condition\">...</div>`\n * - `<div template=\"if condition\">...</div>`\n * - `<template [if]=\"condition\"><div>...</div></template>`\n *\n * @exportedAs angular2/directives\n */\n@Viewport({\n selector: '[if]',\n properties: {\n 'condition': 'if'\n }\n})\nexport class If {\n viewContainer: ViewContainer;\n prevCondition: boolean;\n\n constructor(viewContainer: ViewContainer) {\n this.viewContainer = viewContainer;\n this.prevCondition = null;\n }\n\n set condition(newCondition) {\n if (newCondition && (isBlank(this.prevCondition) || !this.prevCondition)) {\n this.prevCondition = true;\n this.viewContainer.create();\n } else if (!newCondition && (isBlank(this.prevCondition) || this.prevCondition)) {\n this.prevCondition = false;\n this.viewContainer.clear();\n }\n }\n}\n"]}