below is my code i need to get username controller is loginname i need to 
get the name 




function loginname($scope) {
       
   

    var context = SP.ClientContext.get_current();
    var user = context.get_web().get_currentUser();
    var name;


    angular.element(document).ready(function () {
        getUserName();

        context.load(user);

        context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);

    });

   

    // This code runs when the DOM is ready and creates a context object 
which is needed to use the SharePoint object model
   // $(document).ready(function () {
       // getUserName();
   // });

    // This function prepares, loads, and then executes a SharePoint query 
to get the current users information
    function getUserName() {
        context.load(user);
      
        context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
    }

    // This function is executed if the above call is successful
    // It replaces the contents of the 'message' element with the user name
    function onGetUserNameSuccess() {
        $('#message').text('Hello ' + user.get_title());
       
        name = user.get_title();
        alert(name);
       
      
    }

    // This function is executed if the above call fails
    function onGetUserNameFail(sender, args) {
        alert('Failed to get user name. Error:' + args.get_message());
    }



   $scope.lastName = name;
   // alert("sssssssss"+name);


    //var userid = _spPageContextInfo.userId;
    //var requestUri = _spPageContextInfo.webAbsoluteUrl + 
"/_api/web/getuserbyid(" + userid + ")";
    //var requestHeaders = { "accept": "application/json;odata=verbose" };

   
    //$http({ method: 'GET', url: requestUri, headers: requestHeaders 
}).success(function (data) {
    //    $scope.collection = data;
    //    // response data 
    //});
    }

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to