Javascript JQuery选择器在AngularJS控制器中不工作
我有一个viewA和相应的控制器,但在viewA上单击一个图像时,我必须导航到另一个ViewB和相应的控制器B,在ViewB中有一些复选框,然后在ViewB上有一个按钮将我们带到viewA,然后我想再次单击viewA上的图像,导航到ViewB并恢复复选框值(选中,未选中)。我已将复选框的值存储到服务变量Javascript JQuery选择器在AngularJS控制器中不工作,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我有一个viewA和相应的控制器,但在viewA上单击一个图像时,我必须导航到另一个ViewB和相应的控制器B,在ViewB中有一些复选框,然后在ViewB上有一个按钮将我们带到viewA,然后我想再次单击viewA上的图像,导航到ViewB并恢复复选框值(选中,未选中)。我已将复选框的值存储到服务变量 <body ng-app='demo'> <script type="text/ng-template" id="home.html"> <h1> v
<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>
:soo问题是???无法使用jquery选择器$(“#checkBoxId”).prop('checked',serviceVariableValue);发布您的代码或您尝试过的内容。if(EatService.goingToFilter==true){if($scope.providerName='zomato'){$('rated').prop('checked',EatService.rated);}
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'
});
});