Reputation: 4502
I am using TypeScript almost entire of my client project. Currently I am facing a technical problem.
In my HTML, I have an anchor tag like below :
<a class="btn btn-default mrm" ui-sref="course-detail({courseId: '{{c.Id}}'})">Details</a>
In my course detail controller, I am getting the values in the stateparam variable. But if I want to access my 'courseId' from that variable, it is giving me build error. Please check the image below.
But if I remove the IF block, then I am getting the log in the developer console like below.
I must get the course Id property and value to proceed. Otherwise I need to code this controller in pure angularjs which I don't want. Thanks.
Upvotes: 2
Views: 1446
Reputation: 667
Typescript prefers to work on maps explicitly through brackets notation [].
If you want to get a field out of a map-like object you should use square brackets instead of dot notation:
if (this.param['courseId'] === "00000....0000") {
//.. rest of the code
That should solve the immediate issue you're facing.
Upvotes: 6