我用angularjs和firebase构建了一个登录表单。到目前为止还不错--但是如果登录尝试不正确,我需要传递一个“重置密码”链接回视图。看起来是这样的:
ref.authWithPassword({
email: $scope.account.email, password: $scope.account.password
}, function(error, authData){
if(error){
$scope.$apply(function() {
// this part isn't working
// also tried: $scope.authMsg = 'Incorrect credentials. <a href="reset">Reset password?</a>';
var reset = 'Reset password?';
reset.link("/pages/recover/");
$scope.authMsg = 'Incorrect credentials. '+reset;
});
} else {
$scope.$apply(function() {
$state.go('app.dashboard');
});
}
}除了恢复密码链接之外,所有这些都可以正常工作--在$scope.authMsg值中创建链接的正确方法是什么?link()根本不起作用,如果我只想在返回字符串中编写a标记,它就会打印原始HTML,而不是将其解释为链接。
发布于 2015-01-10 18:39:22
如果要在$scope.authMsg中显示链接,可以使用$sce服务并将安全html绑定到具有ng- bind指令的元素。
$scope.authMsg = $sce.trustAsHtml('<a href="">Reset Password</a>');检查这个柱塞,例如ng-bind和$sce.trustAsService('')示例。
https://stackoverflow.com/questions/27879654
复制相似问题