gpt4 book ai didi

angular - ng如果无法立即使用(Angular Dart)

转载 作者:行者123 更新时间:2023-12-03 04:16:50 24 4
gpt4 key购买 nike

我在WebStorm中创建了一个新项目,该项目产生了一些示例代码。到目前为止,我所做的唯一修改就是在ngIf中添加了index.html:

<!DOCTYPE html>
<html>
<head>
(some boilerplate stuff)
</head>
<body>

<div *ngIf="false"> //ALSO TRIED PUTTING THIS IN my-app
<my-app >Loading...</my-app>
</div>
</body>
</html>

运行此程序时,我希望看到一个空网页,但实际上最终得到了“待办事项 list ”示例应用程序。我是否错过了一些显而易见的事情?我已经重新加载了该项目,但没有任何更改。

在一些样板示例代码下面(我在这里添加的只是 CORE_DIRECTIVES):

主镖
 void main() {  bootstrap(AppComponent);}

app_component.dart
@Component(
selector: 'my-app',
styleUrls: const ['app_component.css'],
templateUrl: 'app_component.html',
directives: const [CORE_DIRECTIVES, materialDirectives, TodoListComponent],
providers: const [materialProviders],
)
class AppComponent {

}

最佳答案

指令和组件在Angular组件模板中仅起作用。

在组件模板之外,它们只会被忽略。
您可以使用dart:html在Angular外部修改DOM,例如,仅在使用bootstrap(AppComponent)添加<my-app >Loading...</my-app>后才运行dart:html

关于angular - ng如果无法立即使用(Angular Dart),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50822426/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com