Jefferson
Jefferson

Reputation: 57

Typescript Uncaught ReferenceError: notifyOwner is not defined

I have a project where I just added a button with an onclick event and in my reviewservice.ts I then entered an function into ReviewService.ts. When I build the project and click the button I am getting notifyOwner is not defined is there anything page where I need to move the function?

ReviewPage.html

<div style="text-align: center;">
    <button class="btn btn-default" type="button" onclick="notifyOwner(reviewer)">Review Complete</button>
</div>

In ReviewService.ts

notifyOwner(reviewerId: number): Observable<void> {
    let data: NotifyReviewerRequest = {
        ReviewerId: reviewerId
    };

    return this.http
        .post(this.apiUrls.NotifyReviewer, data, this.options)
        .catch(this.errorHandler)
        .map(response => undefined);
}

Upvotes: 0

Views: 188

Answers (1)

user4799206
user4799206

Reputation:

You should add the function to the corresponding component or call a different function in your component that uses your service.

and make sure that your component contains:

templateUrl: 'ReviewPage.html

html files can only reach the functions that are in .ts files contains the templateUrl: 'ReviewPage.html.

other way is that you can add service to your component file, then call user service function in that file.

Upvotes: 1

Related Questions