我是angularjs的新手.
我的问题是我有一个用于处理登录和注销的用户控制器.我还有另一个控制器来加载我的网站的标题菜单.
如果用户登录到站点,则我的isAuthenticated变量设置为true.如果变量设置为true,则标题应该更改但是,我认为必须重新加载控制器才能更改标题视图.
这里是我的HeaderController的代码:
myapp.controller('HeaderController', ['$scope', '$location', '$window', 'AuthenticationService',
function HeaderController($scope, $location, $window, AuthenticationService) {
$scope.isAuthenticated = AuthenticationService.isAuthenticated;
if (AuthenticationService.isAuthenticated) {
$scope.user.vorname = $window.sessionStorage.user.vorname;
}
}
]);
Run Code Online (Sandbox Code Playgroud)
这是我的HeaderDirective的代码:
myapp.directive('appHeader', function() {
return {
restrict: 'E',
link: function(scope, element, attrs) {
if (attrs.isauthenticated == 'false') {
scope.headerUrl = 'views/header/index.html';
} else {
scope.headerUrl = 'views/header/isAuthenticated.html';
}
},
template: '<div ng-include="headerUrl"></div>'
}
});
Run Code Online (Sandbox Code Playgroud)
我的index.html:
<div ng-controller="HeaderController">
<app-header isauthenticated="{{isAuthenticated}}"></app-header>
</div>
Run Code Online (Sandbox Code Playgroud)
如果用户登录页面,如何重新加载控制器?
PS:请原谅我糟糕的发音.
我会在AngularJS中使用summernote.我找到了https://github.com/outsideris/angular-summernote,但这对我不起作用.我唯一得到的是一个错误
错误:undefined不是函数(评估'element.summernote(summernoteConfig)')
我已经包含了所有必需的文件,如jquery,bootstrap,summernote等.
我的第二个想法是在没有角度 - summernote指令的情况下使用夏季音符.但这也不应该完美.
如果我试试
$(document).ready(function() {
$('.summernote').summernote();
});
Run Code Online (Sandbox Code Playgroud)
summernote不起作用,但如果我试试...... 喜欢
$.getScript('//cdnjs.cloudflare.com/ajax/libs/summernote/0.5.1/summernote.min.js',function(){
$('#summernote').summernote();
});
Run Code Online (Sandbox Code Playgroud)
它有效,但我会使用我的本地副本summernote,所以第二个不是我需要的
希望你理解我的问题并感谢任何帮助Rico