刚写了一堆,断线...简单求助一下,在ionic router中,使用了model,结果只能第一次
显示和访问到,后续页面值变动,反馈不到$scope中,debug一下,看到在this中起了一个
新对象,不知什么机制。直接上代码
<!DOCTYPE html>
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,
maximum-scale=1, user-scalable=no, width=device-width">
<link href="http://www.runoob.com/static/ionic/css/ionic.min.css"
rel="stylesheet">
<script src="http://www.runoob.com/static/ionic/js/ionic.bundle.min.js">
</script>
</head>
<body>
<ion-nav-bar class="bar-positive">
<ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view></ion-nav-view>
<script id="templates/tabs.html" type="text/ng-template">
<ion-tabs class="tabs-icon-top tabs-positive" >
<ion-tab title="Home" icon="ion-home" href="#/tab/home">
<ion-nav-view name="home-tab"></ion-nav-view>
</ion-tab>
</ion-tabs>
</script>
<script id="templates/facts.html" type="text/ng-template">
<ion-view view-title="Facts" >
<ion-content class="padding">
<input type="text" name="hello" ng-model="Hello">
<button id="Request_Picture" class="button"
ng-click="sayHello()">测试Model</button>
</ion-content>
</ion-view>
</script>
<script type="text/javascript">
var myApp = angular.module('ionicApp', ['ionic']);
myApp.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('tabs', {
url: "/tab",
abstract: true,
templateUrl: "templates/tabs.html"
})
.state('tabs.facts', {
url: "/facts",
views: {
'home-tab': {
templateUrl: "templates/facts.html",
controller: 'FactsCtrla'
}
}
});
$urlRouterProvider.otherwise("/tab/facts") ;
});
myApp.controller('FactsCtrla', function($scope, $window) {
$scope.Hello = "first";
$scope.sayHello = function(){
$window.alert("$scope.Hello:" + $scope.Hello + "\n"
+ "this.Hello:" + this.Hello);
console.log("$scope.Hello:" + $scope.Hello + "\n"
+ "this.Hello:" + this.Hello);
};
});
</script>
</body>
</html>
--
修改:XMI FROM 219.142.1.*
FROM 219.142.1.*