0
Personal greetings, I am developing an app with login and I am using Angularjs, but I have a cruel doubt when logging in the user.
It turns out that I am using the user menu via Directive, when the user is not logged in to the system it shows the default links (Sign in, Register, etc...), but even after the user logs into the system it remains the same menu. I would like when the user logs in he reloads the Directive from the menu to show the user options.
My Directive is the following:
app.directive("menuAluno", function() {
var linker = function(scope, element, attrs) {
// DO SOMETHING
}
return {
templateUrl: "menu",
scope: { menuAluno: '=menuAluno' },
controller: "menuCtrl"
};
});
Thanks friend for the answer, there is some way Directive is "watching" the object change so it update the menu without having to refresh the page when the user logs in?
– Herbeth Santana
has yes, you can put a $watch() inside the directive by listening to the objAluno and when it is changed it executes the <code>Scope.urlMenu = (Scope.ubjAluno ? 'menu-student.html' 'menu-defalt.html');</code> so they would be checking the user value always, from a glance at the $watch $apply and $Digest to better understand the date bind of the Angularjs, here is an example of $Whatch() http://jsfiddle.net/user2314737/jmf6kL3n/ in this example he is listening to an ng-model="myName" and saying if it is larger or more than 5 characters
– Marcos Henrique
Thank you again for the help, I will take a test... I am very grateful. :)
– Herbeth Santana