如何从角度js中的html脚本块调用控制器内的函数

时间:2016-03-15 10:41:00

标签: javascript jquery angularjs

我在angularjs Controller中使用Jquery代码并调用该控制器内的函数。但它没有调用该函数,我收到的错误称为“Uncaught ReferenceError:deleteMedication未定义”。

confirm(medication_id) {
        console.log(medication_id);
        $(".confirm").popover({
            title: 'Are you sure?',
            content: '<p><a type="button" class="btn next-btn popup-btns" onclick="deleteMedication(this.medication_id);">Yes</a><a type="button" class="btn cancel-btn mrgn-L10 popup-btns" onclick="hideConfirm()">No</a></p>',
            placement: 'left',
            html: true

        });
    }


    /**
     * Delete Medication Details
     * @param  {Number} medication_id This is the medication id that needs to be passed
     */
    deleteMedication(medication_id) {
        this.VitalInformationService.deleteMedication(this.AuthService.getParticipantDashboardId(), medication_id).then(data => {
            /*Notification for Diagnosis Deletion*/
            this.ngToast.create({
                content: 'Medication Deleted Successfully.',
                className: 'danger',
                dismissButtonHtml: '&times',
                dismissOnTimeout: true,
                timeout: 3000
            });
            //List of Medication
            this.VitalInformationService.listMedication().then(data => {
                this.medications = data;
            }, error => {
                console.log("Error in fetching Medication")
            });

        });
    }

我也试着用“this.deleteMedication(this.medication_id)”打电话。但它没有用。任何人都可以提供解决方案......

0 个答案:

没有答案