首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Angular HTML template的解析位置

文件:

compiler.umd.js

path:

turbo_modules/@angular/compiler@9.1.12/bundles:

函数名:TemplateParser.prototype.parse

代码语言:javascript
复制
TemplateParser.prototype.parse = function(component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces) {
                    var result = this.tryParse(component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces);
                    var warnings = result.errors.filter(function(error) {
                        return error.level === exports.ParseErrorLevel.WARNING;
                    });
                    var errors = result.errors.filter(function(error) {
                        return error.level === exports.ParseErrorLevel.ERROR;
                    });
                    if (warnings.length > 0) {
                        this._console.warn("Template parse warnings:\n" + warnings.join('\n'));
                    }
                    if (errors.length > 0) {
                        var errorString = errors.join('\n');
                        throw syntaxError("Template parse errors:\n" + errorString, errors);
                    }
                    return {
                        template: result.templateAst,
                        pipes: result.usedPipes
                    };
                }

如果把form后面中括号的formGroup改成formGroup2:

错误消息:Can’t bind to ‘formGroup2’ since it isn’t a known property of ‘form’. ("

检查逻辑位于compiler.umd.js里的TemplateParseVisitor.prototype._checkPropertiesInSchema函数:

检查的具体细节:Schema里包含的form元数据:

报错:

下一篇
举报
领券