角app结构:
<app><div content><a href="#" (click)="show()">click me</a></div></app>
内容组件模板:
<ng-content></ng-content>
component有公共方法show(),但是当我单击此链接时,会得到:
Error: EXCEPTION: Error during evaluation of "click"
ORIGINAL EXCEPTION: Type
在学习angular2时,遇到了这两种从输入字段读取值的方法,如下所示:
<input type="text"[(ngModel)]="pname"> // I can read the value from --> pname
<input type="text" (keyup)="addvalue($event)"> // I can check for enter press and read text
例如,如果我想写一个ToDo应用程序,并要求用户在输入字段中输入列表,在单击Add按钮后,可
我有以下从服务器接收的数据
{
name: "Sam {{{{aaa}}}}"
}
在angular中,我使用以下代码将其打印出来
<span>{{name}}</span>
预期输出为
<span>Sam {{{{aaa}}}}</span> <!-- I dont want the curly braces here to act as a variable -->
但它抛出了一个错误。看起来Angular也在尝试插入字符串name。如何告诉Angular将其视为惰性字符串而不是变量?
我还探索了使用自定义