0% found this document useful (0 votes)
22 views1 page

App - JS:: Controller Log

This document defines an AngularJS application with a controller that manages a list of users. The controller initializes an empty user object, displays an existing list of users, adds new users to the list when a save function is called, selects a user for deletion, deletes the selected user by removing it from the list, and clears info messages.

Uploaded by

Eric Alberto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

App - JS:: Controller Log

This document defines an AngularJS application with a controller that manages a list of users. The controller initializes an empty user object, displays an existing list of users, adds new users to the list when a save function is called, selects a user for deletion, deletes the selected user by removing it from the list, and clears info messages.

Uploaded by

Eric Alberto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

app.

js: 
var myApp = angular.module("myApp", []);

myApp.controller("myController", function($scope){
console.log("in controller...");
$scope.newUser = {};
$scope.info = "";

$scope.users = [
{username: "rimon", fullName: "Md. Mamunur Rashid Rimon",
email:"[email protected]"},
{username: "shamim", fullName: "Md. Tamim Hossain",
email:"[email protected]"},
{username: "tamim", fullName: "Tamim Iqbal",
email:"[email protected]"}
];

$scope.saveUser = function(){
console.log("Saving...");
$scope.users.push($scope.newUser);
$scope.info = "New User Added Successfully!";
$scope.newUser = {};
};

$scope.selectUser = function(user){
$scope.clickedUser = user;
};

$scope.deleteUser = function(){
console.log($scope.users.indexOf($scope.clickedUser));
$scope.users.splice($scope.users.indexOf($scope.clickedUser), 1);
$scope.info = "User Deleted Successfully!";
};

$scope.clearInfo = function(){
$scope.info = "";
};
});

You might also like