This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular | |
.module('yourtube', [ | |
'ngCookies', | |
'ngRoute', | |
'ngStorage', | |
'ngMessages', | |
'angularMoment', | |
'angular-loading-bar', | |
'ui.bootstrap', | |
'appRoutes', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var appRoutes = angular.module('appRoutes', []); | |
appRoutes.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider){ | |
$routeProvider | |
.when('/', { | |
templateUrl: './views/pages/home.client.view.html' | |
}) | |
.when('/auth/signup', { | |
templateUrl: './views/account/create-user.client.view.html', | |
controller: 'AuthController', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="panel panel-default"> | |
<div class="panel-heading">Recommended</div> | |
<div class="panel-body"> | |
<div class="row"> | |
<div class="col-sm-4"> | |
<h5>PHP Programming</h5> | |
<!-- 4:3 aspect ratio --> | |
<div class="embed-responsive embed-responsive-4by3"> | |
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/7TF00hJI78Y"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="row"> | |
<div class="center-form panel"> | |
<div class="panel-body"> | |
<h2 class="text-center">Log in</h2> | |
<form method="post" ng-submit="login()" name="loginForm"> | |
<div class="form-group has-feedback"> | |
<input class="form-control input-lg" type="text" name="email" ng-model="user.email" placeholder="Email" required autofocus> | |
<span class="ion-at form-control-feedback"></span> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.controller('AuthController', ['$scope','$location','$auth','toastr', function($scope, $location, $auth, toastr) { | |
$scope.login = function() { | |
$auth.login($scope.user) | |
.then(function() { | |
toastr.success('You have successfully signed in!'); | |
$location.path('/'); | |
}) | |
.catch(function(error) { | |
toastr.error(error.data.message, error.status); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="row"> | |
<div class="center-form panel"> | |
<div class="panel-body"> | |
<h2 class="text-center">Sign up</h2> | |
<form method="post" ng-submit="signup()" name="signupForm"> | |
<div class="form-group has-feedback" ng-class="{ 'has-error' : signupForm.displayName.$invalid && signupForm.displayName.$dirty }"> | |
<input class="form-control input-lg" type="text" name="fullName" ng-model="user.fullName" placeholder="Name" required autofocus> | |
<span class="ion-person form-control-feedback"></span> | |
<div class="help-block text-danger" ng-if="signupForm.fullName.$dirty" ng-messages="signupForm.fullName.$error"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.signup = function() { | |
$auth.signup($scope.user) | |
.then(function(response) { | |
$auth.setToken(response); | |
$location.path('/'); | |
toastr.info('You have successfully created a new account and have been signed-in'); | |
}) | |
.catch(function(response) { | |
console.log(response); | |
toastr.error(response.data.message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.controller('ProfileController', ['$scope','$http','toastr','User', function($scope, $http, toastr, User) { | |
$scope.getProfile = function() { | |
User.getProfile() | |
.then(function(response) { | |
$scope.user = response.data; | |
}) | |
.catch(function(response) { | |
toastr.error(response.data.message); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory('User', ['$http', function($http) { | |
return { | |
getProfile: function(){ | |
return $http.get('/api/me'); | |
}, | |
updateProfile: function(profile){ | |
return $http.put('/api/me', profile); | |
} |