@docs-private
()
| 125 | |
| 126 | /** @docs-private */ |
| 127 | ngOnInit() { |
| 128 | // Collect contents, insert and compile template |
| 129 | const attachChildNodes: ɵangular1.ILinkFn | undefined = this.helper.prepareTransclusion(); |
| 130 | const linkFn = this.helper.compileTemplate(); |
| 131 | |
| 132 | // Instantiate controller |
| 133 | const controllerType = this.directive.controller; |
| 134 | const bindToController = this.directive.bindToController; |
| 135 | let controllerInstance = controllerType |
| 136 | ? this.helper.buildController(controllerType, this.$componentScope) |
| 137 | : undefined; |
| 138 | let bindingDestination: ɵupgradeHelper.IBindingDestination; |
| 139 | |
| 140 | if (!bindToController) { |
| 141 | bindingDestination = this.$componentScope; |
| 142 | } else if (controllerType && controllerInstance) { |
| 143 | bindingDestination = controllerInstance; |
| 144 | } else { |
| 145 | throw new Error( |
| 146 | `Upgraded directive '${this.directive.name}' specifies 'bindToController' but no controller.`, |
| 147 | ); |
| 148 | } |
| 149 | this.controllerInstance = controllerInstance; |
| 150 | this.bindingDestination = bindingDestination; |
| 151 | |
| 152 | // Set up outputs |
| 153 | this.bindOutputs(bindingDestination); |
| 154 | |
| 155 | // Require other controllers |
| 156 | const requiredControllers = this.helper.resolveAndBindRequiredControllers(controllerInstance); |
| 157 | |
| 158 | // Hook: $onChanges |
| 159 | if (this.pendingChanges) { |
| 160 | this.forwardChanges(this.pendingChanges, bindingDestination); |
| 161 | this.pendingChanges = null; |
| 162 | } |
| 163 | |
| 164 | // Hook: $onInit |
| 165 | if (this.controllerInstance && ɵutil.isFunction(this.controllerInstance.$onInit)) { |
| 166 | this.controllerInstance.$onInit(); |
| 167 | } |
| 168 | |
| 169 | // Hook: $doCheck |
| 170 | if (controllerInstance && ɵutil.isFunction(controllerInstance.$doCheck)) { |
| 171 | const callDoCheck = () => controllerInstance?.$doCheck?.(); |
| 172 | |
| 173 | this.unregisterDoCheckWatcher = this.$componentScope.$parent.$watch(callDoCheck); |
| 174 | callDoCheck(); |
| 175 | } |
| 176 | |
| 177 | // Linking |
| 178 | const link = this.directive.link; |
| 179 | const preLink = typeof link == 'object' && link.pre; |
| 180 | const postLink = typeof link == 'object' ? link.post : link; |
| 181 | const attrs: ɵangular1.IAttributes = NOT_SUPPORTED; |
| 182 | const transcludeFn: ɵangular1.ITranscludeFunction = NOT_SUPPORTED; |
| 183 | if (preLink) { |
| 184 | preLink(this.$componentScope, this.$element, attrs, requiredControllers, transcludeFn); |
nothing calls this directly
no test coverage detected