1

I am using Laravel and angular js

I follwed this Link tutorial everthing is working fine but my problem is i don't know how to display Login customer name and mail id

(function() {

    'use strict';

    angular
        .module('authApp')
        .controller('UserController', UserController);  

    function UserController($http) {

        var vm = this;

        vm.users;
        vm.error;

        vm.getUsers = function() {

            // This request will hit the index method in the AuthenticateController
            // on the Laravel side and will return the list of users
            $http.get('api/authenticate').success(function(users) {
                vm.users = users;
            }).error(function(error) {
                vm.error = error;
            });
        }
    }

})();

1 Answer 1

2

You need to access to vm.users object.

First, you have to alias your controller in your view.

<div ng-controller="UserController as user">

Your controller (this) becomes accessible with user.

Then you have to iterate your users object with ngRepeat directive.

<span ng-repeat="iteratedUser in user.users">

Full view code:

<div ng-controller="UserController as user">
    <span ng-repeat="iteratedUser in user.users">
        Name: {{iteratedUser.name}}
    </span>
</div>

If you need more explanations, tell me in comments :)

Edit: Don't forget to call your getUsers function! Else, data won't be fetched.

Sign up to request clarification or add additional context in comments.

13 Comments

Sorry i need current Login customer name only
Then just display customer name :) I'm editing answer
No not display anything
Please you need to show more code, possible errors in console etc.
No error my full code here scotch.io/tutorials/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.