ionic ng-bind-html

1、ionic ng-bind-html 指令

ng-bind-html 指令是通一个安全的方式将内容绑定到 HTML 元素上。

2、html

<element ng-bind-html="model.htmlStr"></element>
<element ng-bind-html="formatProperty(item.VendorInfo.Property)"></element>

<span class="item-note text-orange" ng-bind="formatPaymentType(model.deliveryDetail.PaymentTypeId)"></span>
<span class="badge badge-assertive"><i class="icon ion-flash"></i>&nbsp; {{formatOrderState(model.deliveryDetail.OrderState)}}</span>

3、controller

app.controller('MessageCtrl', function ($scope, $sce) {
    $scope.model = {
        "htmlStr": $sce.trustAsHtml('<i class="icon ion-tips">hello</i>')
    };

    $scope.displayProperty = function (property) {
        switch (property) {
            case 1:
                return $sce.trustAsHtml('<i class="icon ion-tips">hello</i>');
            case 2:
                return $sce.trustAsHtml('<i class="icon ion-tips">world</i>');
            case 3:
                return $sce.trustAsHtml('<i class="icon ion-tips">hello</i> <i class="icon ion-tips">world</i>');
            default:
                return $sce.trustAsHtml('<i class="icon ion-tips">hello</i>');
        }
    }

    $scope.formatPaymentType = function (type) {
        switch (type) {
            case 1:
                return "货到付款";
            case 2:
                return "在线支付";
            case 3:
                return "在线支付";
            case 4:
                return "在线支付";
            case 5:
                return "代金券";
            default:
                return "在线支付123";
        }
    }

    $scope.formatOrderState = function (type) {
        switch (type) {
            case 0:
                return "等待商户响应";
            case 1:
                return "交易已完成";
            case 2:
                return "商户已接单";
            case 3:
                return "商户已接单";
            default:
                return "555666";
        }
    }

});



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值