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EAAK,CAAA,IAAG,cAAc,CAAC,CAAG;AAC/E,SAAG,cAAc,EAAI,MAAI,CAAC;AAC1B,SAAG,cAAc,MAAM,AAAC,EAAC,CAAC;IAC5B;AAAA,EACF,MAlDmF;AAArF,KAAK,eAAe,AAAC,mBACb,EAAC,GAAE,CAAG,UAAS,AAAD,CAAG;AAAC,cA0BzB,SAAO,AAAC,CAAC;AACR,aAAO,CAAG,OAAK;AACf,eAAS,CAAG,EACV,WAAU,CAAG,KAAG,CAClB;AAAA,IACF,CAAC,EA/BgD;EAAC,CAAC,CAAC,CAAC;AADrD,KAAK,eAAe,AAAC,kBACb,EAAC,GAAE,CAAG,UAAS,AAAD,CAAG;AAAC,YAoCG,aAAY,GApCQ;EAAC,CAAC,CAAC,CAAC;AAmDrD","file":"angular2/src/directives/if.js","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"]}