Error image
json 형식으로 개체에 액세스 할 수 있지만 모든 속성과 값을 볼 수는 있지만 수행 할 수는 없습니다. 개별 속성 값에 액세스하십시오.json 형식의 개체를 읽을 수 있지만 Angular2의 속성을 읽을 수 없음
전적으로 도움을 주셔서 감사합니다. 코드 아래
example.html
<label>Name:</label>
<input type="text" [(ngModel)]="yourName" placeholder="Enter a name here">
<input type="number" [(ngModel)]="age" placeholder="Enter age here">
<br>
<button (click)="send({ name : yourName, age : age})">send</button>
<h1 [hidden]="!yourName">Hello {{yourName}}!</h1>
{{myobj | json}}
{{myobj.name}}
example.ts
import {Component} from 'angular2/core';
@Component({
selector: 'hello-world',
templateUrl: 'src/hello_world.html'
})
export class HelloWorld {
yourName: string = '';
myname : string;
myage : number;
send : any (obj){
console.log(obj);
this.myobj = obj;
}
}
에 대한 링크가 어디'myobj'이 정의인가? – cyberpirate92
구문이 맞습니까? 나는 그것이 이어야한다고 생각한다. send : any = (obj) => { console.log (obj); this.myobj = obj; }' – cyberpirate92
귀하의 제안을 모두 시도했지만 여전히 속성 값을 표시 할 수 없습니다. 그러나 나는 그것을 조작 할 수있다. – kkom