2015-12-07 37 views
0

服務器返回代碼html,我會在頁面中插入此代碼。但如果我插入jQuery,角度指令不起作用。 我的代碼到控制器:如何將Html代碼從服務器插入到Angular中?

$scope.submit = function() { 
      $http({ 
       method: 'POST', 
       url: 'find.php', 
       data:{url:$scope.url} 
        }).then(function successCallback(response) { 
        $("#center").remove(); 
        var data=response.data; 
        $("#result").html(data); 

        }, function errorCallback(response) { 
        $("#center").remove();   
        $("#result").html("ERRORE"); 
        }); 

      } 

這個例子是在Jquery的。如何在Angular?

+0

http://stackoverflow.com/questions/19845950/angularjs-how-to-dynamically-add-html-and-bind-to-controller – akgaur

回答

0

在您的成功處理程序中,您可以將響應數據存儲到$scope變量中,如$scope.data=response.data;。然後你可以在你的html中使用ng-bind="data"

ng-bind將呈現存儲在$scope.data視圖中的html。

Reference

+0

沒有的功能,因爲DOM頁面不刷新。 – Riccardo

相關問題