<body ng-app='demo'>
<script type="text/ng-template" id="home.html">
<h1> viewA </h1>
<a href="#/about"><img src="src" /></a>
</script>
<script type="text/ng-template" id="about.html">
<h1> viewB </h1>
<h4>Click me to see ViewA: <input id="myCheckBox" type="checkbox" ng-model="checked" ng-change='checkView()'></h4>
</script>
<div>
<div ng-view></div>
</div>
</body>
スクリプト:
var demo = angular.module('demo', []);
demo.controller('HomeController', function ($scope) {});
demo.controller('AboutController', function ($scope,$location) {
$scope.checkView=function(){
//if($scope.checked)
if($('#myCheckBox').prop('checked') == true)
$location.url('/home');
}
});
demo.config(function ($routeProvider) {
$routeProvider.
when('/home', {
templateUrl: 'home.html',
controller: 'HomeController'
}).
when('/about', {
templateUrl: 'about.html',
controller: 'AboutController'
}).
otherwise({
redirectTo: '/home'
});
});
TRY THIS CODE:
秀質問があります? –
jqueryセレクタ$( "#checkBoxId")を使用してcheckBoxesを選択できません。prop( 'checked'、serviceVariableValue); –
あなたのコードやあなたが試したことを投稿してください。 –