學了幾天終於對Cordova_Angular 有點明白了,什麼希望不是錯覺@@!!
前端
</head>
<body ng-app="App" ng-controller="HomeCtrl">
<ion-header-bar class="bar-positive" align-title="center">
<h1 class="title">WIFI熱點</h1>
</ion-header-bar>
<ion-content class="padding">
<!--angular方法ng-repeat-->
<div class="list card" ng-repeat="hotspot in hotspots">
<div class="item item-text-wrap">
<h2>熱點:{{hotspot.spot_name}}</h2>
<p>提供:{{hotspot.company}}</p>
</div>
</div>
</ion-content>
<ion-footer-bar class="bar-calm">
</ion-footer-bar>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="scripts/platformOverrides.js"></script>
<script src="lib/ionic/js/ionic.bundle.min.js"></script>
<script src="scripts/WIFISpot.js"></script>
</body>
</html>
後端
//$http Ajax呼叫 Angular 提供
app.controller('HomeCtrl', function ($scope, $http) {
//先宣告一個空陣列
$scope.hotspots = [];
//取得網頁內容 ,如果沒有值回傳 null
$http.get('http://data.ntpc.gov.tw/NTPC/od/data/api/IMC123/?$format=json', null)
//then完成後叫用function//如果成功
.then(function (response) {
//回應得到的data 給前面
$scope.hotspots = response.data;
//如果失敗
},function (error) {
//警報錯誤
alert(error);
});
});