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

Javascript 如何从angular js中的html脚本块调用控制器内的函数,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我在angularjs控制器内使用Jquery代码,并在该控制器内调用函数。但它并没有调用那个函数,我得到了一个名为“UncaughtReferenceError:DeleteMedicing未定义”的错误 确认(药物id){ 控制台日志(药物id); $(“.confirm”).popover({ 标题:“你确定吗?”, 内容:“YesNo”, 位置:'左', html:对 }); } /** *删除药物详细信息 *@param{Number}药物id这是需要传递的药物id */ 删除药物(药

我在angularjs控制器内使用Jquery代码,并在该控制器内调用函数。但它并没有调用那个函数,我得到了一个名为“UncaughtReferenceError:DeleteMedicing未定义”的错误

确认(药物id){
控制台日志(药物id);
$(“.confirm”).popover({
标题:“你确定吗?”,
内容:“YesNo

”, 位置:'左', html:对 }); } /** *删除药物详细信息 *@param{Number}药物id这是需要传递的药物id */ 删除药物(药物id){ this.VitalInformationService.DeleteMedicing(this.AuthService.getParticipantDashboardId(),Medicing_id)。然后(数据=>{ /*删除诊断的通知*/ 这个是.ngToast.create({ 内容:“已成功删除药物。”, 类名:“危险”, dismissButtonHtml:“&次”, dismissOnTimeout:是的, 超时:3000 }); //药物清单 这个.VitalInformationService.ListMedicing().then(数据=>{ 此参数=数据; },错误=>{ console.log(“获取药物时出错”) }); }); }

我也试着用“this.deleteMedicing(this.medicing_id)”打电话。但它不起作用。任何人都能给出解决方案吗?

请尝试
ng单击=“DeleteMedicing(this.medicing\u id)”
,而不是
onclick
您必须编译弹出内容。您不能为它提供原始字符串。我也使用了ng click。什么都不是happening@lujcon是的,它应该是手工编译的,或者是ng controller的一部分,或者是一些指令。我知道这不是直接的答案,但是$compile是一个高级主题。也许使用“本机”角度组件比使用jQuery插件更好-例如:
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")
            });

        });
    }