저는 최근에 재스민 프레임 워크로 각도기를 사용하기 시작했으며 자바 스크립트도 새로 도입했습니다. 10 개의 속성이있는 페이지 중 하나에 대해 각 필드에 대해 getText를 사용하고 개체의이 값을 업데이트하려고합니다. 다음은 예제 코드입니다각도기에서 객체 속성을 업데이트하는 방법은 무엇입니까?
Var obj ={}
It('should get the value,function(){
Element(by.id("id of firstfield")).getText().then(function(text){
obj.firstfield = text
Console.log(obj) //this correctly prints the updated object
})
Console.log(obj) // prints empty object. I need to get updated object here.
Element (by.id("id of secondfield")).getText().then(function(text){
obj.secondfield = text
Console.log(obj) //this correctly prints the updated object
})
})
어떻게 값을 바꿀 수 있습니까?
Promises가 JavaScript로 작동하는 방법을 읽는 데 도움이되는 것처럼 들리는데, 이는 좋은 시작 리소스입니다. http://www.html5rocks.com/en/tutorials/es6/promises/ – Jmr