-
Notifications
You must be signed in to change notification settings - Fork 2
/
ObjectController.js
27 lines (27 loc) · 1.01 KB
/
ObjectController.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* Created by Namita malik on 25/4/15.
*/
(function (ng) {
var myApp = ng.module('myApp', []);
myApp.controller('ObjectController', [function () {
var objectController = this;
objectController.student = {name: "Namita", age: "16", class: "XII", school: "BBPS"};
objectController.updateKey = function (newKey, oldKey) {
if (newKey == "") {
delete objectController.student[oldKey];
} else if (newKey !== oldKey) {
objectController.student[newKey] = objectController.student[oldKey];
delete objectController.student[oldKey];
}
};
objectController.updateValue = function (newValue, key) {
objectController.student[key] = newValue;
};
objectController.notSorted = function (object) {
return object ? Object.keys(object) : [];
};
objectController.addNewKey = function () {
objectController.student[""] = "";
};
}]);
})(angular);