|
我在state里面配置了controller: home 然后在home里面有一个input ng-mode为a 在JS中的controller中的$scope.a 并不能获取到a的值。打印出来是undefined.
但是如果我不在state里面配置controller,直接把controller写在ion-content上,a的值能获取。(但我不能这么写,这样写的话不能用到$ionicView.beforeEnter方法)
.state("home", {
url: "/home",
templateUrl: "templates/home.html",
controller:"home"
})
.controller("home",["$scope","$rootScope","data","$ionicLoading","$state","$ionicHistory",function($scope,$rootScope,data,$ionicLoading,$state,$ionicHistory){
$scope.$on('$ionicView.beforeEnter', function() {
$ionicLoading.show({
template: '加载中...'
});
$scope.a = function(){
console.log($scope.asd);
}
});
}])
<ion-view view-title="...">
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left"></button>
</ion-nav-buttons>
<ion-content>
<input type="text" ng-model="asd">
<button ng-click="a()">aaa</button></ion-content></ion-view>
|
|