Skip to content

Commit c96dceb

Browse files
committed
Added users view.
1 parent a1686ac commit c96dceb

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

app/Http/Controllers/UserController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function store()
9494
*/
9595
public function show($id)
9696
{
97-
//
97+
return User::find($id);
9898
}
9999

100100
/**

resources/js/controllers/UserController.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
angular.module('UserController', []).controller('UserController', ['$scope', '$rootScope', 'User', 'Auth', '$localStorage',
22
function ($scope, $rootScope, User, Auth, $localStorage) {
3+
angular.module('UserController', []).controller('UserController', ['$scope', '$rootScope', 'User', 'Auth', '$localStorage', '$location',
4+
function ($scope, $rootScope, User, Auth, $localStorage, $location) {
35
$scope.login = function () {
46
var user = new User({
57
username: this.username,
@@ -23,6 +25,12 @@ angular.module('UserController', []).controller('UserController', ['$scope', '$r
2325
});
2426
user.$save(function (res) {
2527
$location.path('users/view/' + res.id);
28+
29+
$scope.findOne = function () {
30+
var splitPath = $location.path().split('/');
31+
var userId = splitPath[splitPath.length - 1];
32+
$scope.user = User.get({userId: userId});
33+
};
2634
}, function (err) {
2735
console.log(err);
2836
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div ng-controller="UserController" ng-init="findOne()">
2+
<h1>{{user.username}}</h1>
3+
Email: {{user.email}}
4+
</div>

0 commit comments

Comments
 (0)