Node JS 和 Angular 电子邮件验证:无论如何要在响应中发送 html?

Node JS and Angular Email Verification: Anyway to send html in a response?

首先,我想澄清一下,我知道如何在 Angular 中使用在 NodeJS 中创建的 APi。我遇到的问题有点棘手。

我有一个功能可以验证注册时使用的电子邮件:

exports.confirmEmail = function (req, res) {
    ConfirmToken.findOne({
        token: req.params.token
    }, function (err, token) {

        if (err) {
            return res.status(500).send({
                message: "Internal Server Error " + err
            })
        }

        // token is not found into database i.e. token may have expired 
        if (!token) {
            return res.status(400).send({
                message: 'Your verification link may have expired. Please click on resend for verify your Email.'
            });
        }
        // if token is found then check valid user 
        else {
            Account.findOne({
                _id: token._accountId,
                email: req.params.email
            }, function (err, user) {

                if (err) {
                    return res.status(500).send({
                        message: "Internal Server Error " + err
                    })
                }
                // User does not exist
                if (!user) {
                    return res.status(401).send({
                        message: 'The account does not exist'
                    });
                }
                // user is already verified
                else if (user.isVerified) {
                    return res.status(200).send('User has been already verified. Please Login');
                }
                // verify user
                else {
                    // change isVerified to true
                    user.isVerified = true;
                    user.save(function (err) {
                        // error occur
                        if (err) {
                            return res.status(500).send({
                                message: err.message
                            });
                        }
                        // account successfully verified
                        else {
                            return res.status(200).send('Your account has been successfully verified');
                        }
                    });
                }
            });
        }

    })
}

这是我注册账号时得到的回复

现在我的问题是:有没有办法传入 html 代码或让它显示在自定义 Angular 组件中,而不是像这样在网络浏览器上显示为简单的纯文本

您的服务应将 isVerified 状态发送回客户端。您目前只发送一个字符串

return res.status(200).send('Your account has been successfully verified');

基于此状态,我们称它为 isVerified 您的 angular 应用程序将呈现 isVerfiedComponent.ts 或 notVerifiedComponent.ts