頁
<ion-nav-buttons side="left">
<a class="button button-clear" ng-click="backToPhoneCall()"><i class="icon ion-ios-arrow-left"></i>电话量排行</a>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<a class="button button-clear" ng-click="saveParam()">应用</a>
</ion-nav-buttons>
<ion-content>
<p class="list" ng-init="initPage()">
<p class="item item-pider" style="font-size: 17px;">时间范围{{selected}}
</p>
<p class="item">
<select ng-model="selected">
<option>本季度</option>
<option>本月</option>
<option>本周</option>
</select>
</p>
<p class="item item-pider" style="font-size: 17px;">查看范围
</p>
<p class="item" ng-click="goToAddUser()">
</p>
</p>
</ion-content>
控制器
appCtrls.controller('chooseParamPhoneCallCtrl', function ($scope, $state, $stateParams, localStorageService, boardService) {
$scope.initPage=function(){
$scope.selected="";
}
$scope.backToPhoneCall = function () {
$state.go("tab.crm-viewCrmBoardPhoneCalls");
}
$scope.goToAddUser = function () {
var paramChoosePhoneCall = {term: $scope.selected};
console.debug("paramChoosePhoneCall-->>>" + angular.toJson(paramChoosePhoneCall));
//localStorageService.setLocalStorage("paramChoosePhoneCall",paramChoosePhoneCall);
}
})
如程式碼所示,頁面載入之時初始化selected,然後將selected綁定到select,每次改變選擇的內容{{selected}}中能正確顯示改變後的內容,但是當點擊查看範圍下面的p觸發goToAddUser後,在裡面$scope.selected取到的不是選擇後的內容,而是初始化時賦得空值。
後台
這樣就好了
前台把值丟到方法裡 就沒問題了
controller中
雷雷