0
我有這樣一個鏢類寫:傳遞變量在Angular2js /鏢到HTML頁面
@Component(selector: 'my-content', templateUrl: '../../views/example.html', directives: const [NgFor, NgIf, NgStyle, NgClass], pipes: const [LowerCasePipe, JoinByPipe])
class ContentComponent implements OnInit {
@Input()
ContentComponent(@Inject(ContentService) this.contentService, @Inject(LoggerService) this.log) {
}
@override
ngOnInit()
{
this.className = '.Ciao';
}
在example.html的我這樣做
<span class="pull-right channel" [ngClass]="{className}">some content</span>
當我建立這個項目我收到此消息:
<span class="pull-right channel" [ERROR ->][ngClass]="{className}">some content</span>
這是正確的語法嗎?
'@注入(contentService的)'和'@Inject(LoggerService)'是冗餘的,如果字段具有相同的類型。 –