2016-10-25 5 views
3

나는 angular2를 약간 배워서이 문제에 대한 정보를 찾을 수 없습니다. <input> 태그를 자기 닫지 않으면 구문 분석 오류가 발생합니다. 이것은 나를 위해 매우 이상합니다. 또한 버그 인 것 같지만 이에 대한 이유나 토론을 찾을 수 없습니다.angular2 입력이 자동으로 닫히지 않음

@Component({ 
    selector: 'my-app', 
    template: `<h1>My First Angular App</h1> 
     {{greeting}} 
     <br/> 
     {{product.id}} {{product.name}} {{product.price}} 
     <br/> 
     <span [innerHtml]="product.id"></span> 
     <span [innerHtml]="product.name"></span> 
     <span [innerHtml]="product.price"></span> 
     <br/> 
     <input [(ngModel)]="product.id"/> //Here is working correctly 
     ` 
}) 

동일한 방법으로도 구문 분석 오류가 발생합니다.

@Component({ 
    selector: 'my-app', 
    template: `<h1>My First Angular App</h1> 
     {{greeting}} 
     <br/> 
     {{product.id}} {{product.name}} {{product.price}} 
     <br/> 
     <span [innerHtml]="product.id"></span> 
     <span [innerHtml]="product.name"></span> 
     <span [innerHtml]="product.price"></span> 
     <br/> 
     <input [(ngModel)]="product.id"></input> //Here I get a Parse error 
     `   
}) 

이 오류에 대한 도움말 정보 나 링크는 도움이 될 것입니다. 고마워요

답변

3

input 태그는 빈 요소이므로 자동으로 닫아야합니다. Angular 2 템플릿 파서는 매우 엄격합니다.

HTML sepcification이 주제에 대한보다 구체적인 가져옵니다

보이드 요소는 내용이 모델이 결코 어떤 상황에서 내용을 가질 수없는 요소이다. void 요소는 속성을 가질 수 있습니다.

기타 공극 요소는 다음 area, base, br, col, command, embed, hr, img, keygen, link, meta, param, source, trackwbr.

+1

aaah 그건 사실입니다. 나는 그것을 깨닫지 못했습니다. 너무 혼란스러워서 고마워요 !! – acostela