Javascript 有角度的双向装订
下面是我的页面控制器,用户在第一页之后进入该页面,在该页面中输入社区的详细信息,我将其存储在authservice中。当用户注销并从第一页返回otp页时,$scope.community未更新,他仍然看到旧社区。我所犯的错误是什么?如何修改Javascript 有角度的双向装订,javascript,angularjs,data-binding,ionic,Javascript,Angularjs,Data Binding,Ionic,下面是我的页面控制器,用户在第一页之后进入该页面,在该页面中输入社区的详细信息,我将其存储在authservice中。当用户注销并从第一页返回otp页时,$scope.community未更新,他仍然看到旧社区。我所犯的错误是什么?如何修改 .controller('OTPCtrl', function ($scope, $state, HOST_NAME, AuthService, Flash) { if(AuthService.getCommunity()){ $scope.c
.controller('OTPCtrl', function ($scope, $state, HOST_NAME, AuthService, Flash) {
if(AuthService.getCommunity()){
$scope.community = AuthService.getCommunity();
$scope.community.face = HOST_NAME + '/community-logo/' + $scope.community.id;
}
$scope.login = function (data) {
AuthService.verifyOTP(data.OTP).then(function (data, status, headers, config) {
AuthService.setUserProfile(data);
$state.go('app.groups')
}, function (err) {
var message = 'OTP you entered is not correct';
Flash.create('danger', message, 'custom-class');
});
};
})
在下一页中,首次加载后,与社区相关的值均未更改。甚至在我注销并在Authservice中使用更改的值返回此页面后也不会。我认为这是angular的标准行为,即该控制器仅初始化一次,而不是每次初始化。我如何改进它
OTP.html
<ion-view view-title=
"<div class='mainTitle'>
<img class = 'logoBox' src = '{{community.face}}' />
<span class='insInfo'>{{community.name}} <br />
{{community.city}} <br />
{{community.details.phoneNumber}}
</span>
</div>">
<ion-nav-bar class="bar-stable">
//more code
{{community.name}}
</ion-nav-bar>
</ion-view>
//更多代码
{{community.name}
我不确定这是否是根本原因,但主要是我发现您可能误用了ion view。您是否希望视图标题包含您指定的所有HTML?从我看到的爱奥尼亚文档
这个视图标题应该是一个简单的字符串。如果您想在该部分中使用HTML,请改用ionNavTitle
要显示在父ionNavBar上的纯文本标题。有关HTML标题(如图像),请参见ionNavTitle。