如何使用angularjs實現抓取頁面內容

魔豆發表於2016-01-31
<html ng-app="myApp">
<head>
<title>angularjs-ajax</title>
<script type="text/javascript" src="js/angular149/angular.min.js"></script>
</head>
<body ng-controller="ctrl">
<input type="button" value="抓取頁面內容" ng-click="method1()" /> 
<div style="border: 1px solid #ccc;width: 500px;height:400px;">{{content}}</div>
<script>
    var app = angular.module('myApp',[]);
    app.controller("ctrl",function($scope,$http){
        $scope.method1 = function() {
            $http.get("T2.action").then(function (response) {
                $scope.content = response.data;
            });
        };
    });
    </script>    
</body>
</html>

 

相關文章