【问题标题】:Add script tag inside html in angularjs在angularjs中的html内添加脚本标签
【发布时间】:2016-10-26 14:54:21
【问题描述】:

如果 response.statusText == "OK",我想在 paysucc.html 中添加一个脚本标签。这怎么可能?

脚本:

<script src="https://test.oppwa.com/v1/paymentWidgets.js?checkoutId={checkoutId}"></script>

其中 checkoutId 是 response.data.id

Payment.html:

<button type="submit" class="btn-normal pay-btn" ng-click="processpartners()">Pay From Processing partners</button>

Controller.js:

$scope.processpartners = function() {
        var request = $http({
            method: 'POST',
            url: SITE_URL + '/api/processpartners',
            data: {
                amount: $scope.amount,
                currency: $scope.currency,
            },
        }).then(function(response) {                       
            if ((response.statusText == "OK") && (response.status == 200)) {
                $location.path(SITE_URL + '/paysucc', response.data.id).replace();
            }
        });
    };

routes.js:

 when(SITE_URL + '/paysucc', {
        templateUrl: TEMPLATE_URL + '/partials/paysucc.html',
        controller: 'PaymentsuccessController'
    })

【问题讨论】:

标签: angularjs


【解决方案1】:

请尝试此解决方案可能对您有所帮助:

var s = document.createElement("script");
s.type = "text/javascript";
s.src = "http://somedomain.com/somescript";
$("head").append(s);

【讨论】:

    猜你喜欢
    • 2012-12-08
    • 1970-01-01
    • 2015-08-24
    • 1970-01-01
    • 2016-07-18
    • 2020-12-21
    • 2022-07-07
    • 1970-01-01
    • 2014-02-17
    相关资源
    最近更新 更多