Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* My controller */
- .controller('editProfileCtrl', function($scope, $http) {
- // temporarily setting current contact for testing
- $scope.curContact = 2;
- /*
- TO KNOW: using function(data). ng-model="people.name" etc.
- */
- // get database info to populate text fields
- $http.get("/*my database URL, this will be changed so it's abstracted*/")
- .success(function(data) {
- $scope.people = data;
- // syntax for referencing:
- // console.log("name: " + $scope.people[$scope.curContact].name);
- // not sure if I'll use newString yet, but it's here
- var newString = "/*my database URL, this will be changed so it's abstracted*/" + $scope.curContact;
- console.log("newString is: " + newString);
- })
- .error(function(data) {
- console.log('server side error occurred.');
- });
- $scope.changeInfo = function(people) {
- $http.post("/*my database URL, this will be changed so it's abstracted*/", people)
- .success(function(data) {
- });
- } // end changeInfo
- });
- /* My html file */
- <form method="post">
- <div>
- <label for="people.name">Name:</label>
- <input type="text" id="people.name" value="{{people[curContact].name}}"/>
- </div>
- <div>
- <label for="people.phone">Phone:</label>
- <input type="text" id="people.phone" value="{{people[curContact].phone}}"/>
- </div>
- <div>
- <label for="information.email">Email:</label>
- <input type="email" id="people.email" value="{{people[curContact].email}}"/>
- </div>
- <div>
- <label for="information.position">Position:</label>
- <input type="text" id="people.position" value="{{people[curContact].position}}"/>
- </div>
- <button ng-click="changeInfo(people[curContact])" type="submit">Save changes</button>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement