I'm doing my first app in Angular and I have a page where everything is disabled except for a button
. The user, when click on it, everything is enabled and the content of the title change.
Simply are two different classes: one that makes everything opaque and not clickable, the other one makes the normal opacity and makes clickable.
Currently I made this demo with jQuery, triggering a function on click:
function enable() {
document.getElementById('title').innerHTML = "Text2";
$("div").removeClass("disabled");
}
Now, I want to do it in Angular. Actually I've made this:
var app = angular.module("app",[]);
app.controller("MainCtrl",function($scope){
$scope.Text = 'Text1';
$scope.disabledClass = "disabled";
$scope.changeClass = function(){
$scope.Text = 'Text2'; //Change text
$scope.disabledClass = "not-disabled"; //Change class
};
});
Now I have two questions.
- Is this the best approach?
- I will manage the app with a user login and password. How can I do so that the class disabled is activated by default when the user opens for the first time the app, but then remains the class not-disabled for the whole duration of the session (once that presses the button for enable), that remains even if the user goes on in the pages, and that remains until it closes?