Dart:如何解决这个问题?
Dart: How to fix the condition?
我是新手。我使用 IDEA 模板创建了一个 angular 应用程序并插入示例中的代码:
<p *ngIf="true">
Expression is true and ngIf is true.
This paragraph is in the DOM.
</p>
发生错误:
[INFO]
------------------------------------------------------------------------ [INFO] Starting Build [INFO] Updating asset graph completed, took 16ms
[SEVERE] angular on lib/app_component.dart: Template parse errors:
line 6, column 4 of AppComponent: ParseErrorLevel.FATAL: Can't bind to
'ngIf' since it isn't an input of any bound directive. Please check
that the spelling is correct, and that the intended directive is
included in the host component's list of directives.
^^^^^^^^^^^^ [INFO] Running build completed, took 650ms [INFO] Caching
finalized dependency graph completed, took 853ms [SEVERE]
build_web_compilers|entrypoint on web/main.dart (cached): Unable to
find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a
dev_dependency needs to move to a real dependency), or a build failure
(if importing a generated file).
Please check the following imports:
import 'package:untitled1/app_component.template.dart' as ng;
from
untitled1|web/main.dart at 2:1
[SEVERE] build_web_compilers|entrypoint on test/app_test.dart
(cached): Unable to find modules for some sources, this is usually the
result of either a bad import, a missing dependency in a package (or
possibly a dev_dependency needs to move to a real dependency), or a
build failure (if importing a generated file).
Please check the following imports:
import 'package:untitled1/app_component.template.dart' as ng;
from
untitled1|test/app_test.dart at 5:1
[SEVERE] build_web_compilers|entrypoint on
test/app_test.dart.browser_test.dart (cached): Unable to find modules
for some sources, this is usually the result of either a bad import, a
missing dependency in a package (or possibly a dev_dependency needs to
move to a real dependency), or a build failure (if importing a
generated file).
Please check the following imports:
import 'package:untitled1/app_component.template.dart' as ng;
from
untitled1|test/app_test.dart at 5:1
[SEVERE] Failed after 1.6s
如何修复?
您需要在 @Component()
注释中列出您在模板中使用的指令
import 'package:angular/angular.dart'
...
@Component(
selector: 'foo-bar',
templateUrl: 'foo_bar.html',
directives: [coreDirectives /* or NgIf */],
)
我是新手。我使用 IDEA 模板创建了一个 angular 应用程序并插入示例中的代码:
<p *ngIf="true">
Expression is true and ngIf is true.
This paragraph is in the DOM.
</p>
发生错误:
[INFO] ------------------------------------------------------------------------ [INFO] Starting Build [INFO] Updating asset graph completed, took 16ms [SEVERE] angular on lib/app_component.dart: Template parse errors: line 6, column 4 of AppComponent: ParseErrorLevel.FATAL: Can't bind to 'ngIf' since it isn't an input of any bound directive. Please check that the spelling is correct, and that the intended directive is included in the host component's list of directives. ^^^^^^^^^^^^ [INFO] Running build completed, took 650ms [INFO] Caching finalized dependency graph completed, took 853ms [SEVERE] build_web_compilers|entrypoint on web/main.dart (cached): Unable to find modules for some sources, this is usually the result of either a bad import, a missing dependency in a package (or possibly a dev_dependency needs to move to a real dependency), or a build failure (if importing a generated file).
Please check the following imports:
import 'package:untitled1/app_component.template.dart' as ng;
from untitled1|web/main.dart at 2:1[SEVERE] build_web_compilers|entrypoint on test/app_test.dart (cached): Unable to find modules for some sources, this is usually the result of either a bad import, a missing dependency in a package (or possibly a dev_dependency needs to move to a real dependency), or a build failure (if importing a generated file).
Please check the following imports:
import 'package:untitled1/app_component.template.dart' as ng;
from untitled1|test/app_test.dart at 5:1[SEVERE] build_web_compilers|entrypoint on test/app_test.dart.browser_test.dart (cached): Unable to find modules for some sources, this is usually the result of either a bad import, a missing dependency in a package (or possibly a dev_dependency needs to move to a real dependency), or a build failure (if importing a generated file).
Please check the following imports:
import 'package:untitled1/app_component.template.dart' as ng;
from untitled1|test/app_test.dart at 5:1[SEVERE] Failed after 1.6s
如何修复?
您需要在 @Component()
注释中列出您在模板中使用的指令
import 'package:angular/angular.dart'
...
@Component(
selector: 'foo-bar',
templateUrl: 'foo_bar.html',
directives: [coreDirectives /* or NgIf */],
)