【发布时间】:2016-06-02 03:57:58
【问题描述】:
我的 IONIC 应用程序有问题。 我想在 $http.post 之后重新加载我通过 $http.get 从 nodeJS 收到的数据。 这是我的代码:
.controller('todoTodayCtrl',
function($scope, AuthService, API_ENDPOINT, $http, $state, $ionicPopup) {
$http.get(API_ENDPOINT.url + '/today').then(function(result) {
$scope.todaylist = result.data.msg;
});
})
.controller('todoTodayNewCtrl',
function($scope, AuthService, API_ENDPOINT, $http, $state, $ionicPopup){
$scope.today = {
title: ''
};
$scope.todoNewButton = function() {
$http.post(API_ENDPOINT.url + '/today', $scope.today).then(function(result) {
$state.go('menu.todoToday');
}, function(errMsg) {
var alertPopup = $ionicPopup.alert({
title: 'Nelze přidat Todo',
template: errMsg
});
});
};
})
第一页
<ion-view title="Todo Today" ng-controller="todoTodayCtrl">
<ion-content overflow-scroll="true" padding="true" class="has-header">
<ion-list>
<ion-item class="item-divider" ng-repeat="today in todaylist">{{today.title}} - {{today.time}}</ion-item>
<button class="button button-stable button-block " ui-sref="menu.todoTodayNew">Přidat todo</button>
</ion-list>
</ion-content>
和带有表单的页面
<ion-view title="Nové todo today">
<ion-content overflow-scroll="true" padding="true" class="has-header">
<ion-list>
<label class="item item-input">
<span class="input-label">Nový úkol</span>
<input type="text" placeholder="Nová položka" ng-model="today.title">
</label>
<button class="button button-stable button-block " ng-click="todoNewButton()">Přidat todo today</button>
</ion-list>
</ion-content>
【问题讨论】:
标签: angularjs node.js http post ionic-framework