start using angular on form

pull/8/head
Michael Q Larson 2015-01-05 19:01:58 -08:00
parent 41abdae46f
commit 7a47df4e74
4 changed files with 24 additions and 15 deletions

View File

@ -42,3 +42,10 @@ $(document).ready(function() {
}); });
}); });
var profileValidation = angular.module('profileValidation',[]);
profileValidation.controller('profileValidationController', ['$scope',
function($scope) {
$scope.twitterHandle = '@yournamehere';
$scope.user.name = req.user.name;
}
]);

View File

@ -1,23 +1,18 @@
extends ../layout extends ../layout
script.
var freecodecamp = angular.module('freecodecamp',[]);
freecodecamp.controller('freecodecampController', ['$scope',
function($scope) {
$scope.twitterHandle = '@yournamehere'
}
]);
block content block content
.panel(ng-controller="freecodecampController") .panel(ng-controller="profileValidationController")
.container.text-center .container.text-center
h1 Update your profile here: h1 Update your profile here:
form.form-horizontal(action='/account/profile', method='POST') form.form-horizontal(action='/account/profile', method='POST')
input(type='hidden', name='_csrf', value=_csrf) //input(type='hidden', name='_csrf', value=_csrf)
//.form-group
// label.col-sm-3.col-sm-offset-2.control-label(for='name') Name
// .col-sm-4
// input.form-control(type='text', name='name', id='name', value='#{user.profile.name}')
.form-group .form-group
label.col-sm-3.col-sm-offset-2.control-label(for='name') Name label.col-sm-3.col-sm-offset-2.control-label(for='name') Name
.col-sm-4 .col-sm-4
input.form-control(type='text', name='name', id='name', value='#{user.profile.name}') input.form-control(type='text', placeholder='Name', name='name', ng-model='user.name', ng-minlength='3', ng-maxlength='20', required='required', ng-focus='ng-focus', id='name', value='{{user.name}}')
.form-group .form-group
label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (use letters, numbers, underscore) * label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (use letters, numbers, underscore) *
.col-sm-4 .col-sm-4

View File

@ -5,7 +5,7 @@ block content
.panel-body .panel-body
.row .row
.col-xs-2.col-sm-1.col-md-1 .col-xs-2.col-sm-1.col-md-1
img(src="#{picture}") img(src="#{user.picture}")
.col-xs-4.col-sm-2.col-md-2 .col-xs-4.col-sm-2.col-md-2
h2.nameline h2.nameline
= "[ " + user.points + " ]" = "[ " + user.points + " ]"
@ -13,8 +13,15 @@ block content
h2.nameline h2.nameline
= name = name
h4= location h4= location
a(href="#{coderbyteProfile") a(href="http://twitter.com/#{user.profile.twitterHandle}")
|= "@#{twitterHandle} on Twitter"
a(href="#{user.profile.coderbyteProfile")
| Coderbyte Profile | Coderbyte Profile
a(href="#{user.profile.linkedin")
| LinkedIn Profile
a(href="#{user.profile.codepen")
| Codepen Portfolio
a(href=linkedin)
- if (ch[0] > 0) - if (ch[0] > 0)
.container .container
h1 Completed Challenges h1 Completed Challenges

View File

@ -1,5 +1,5 @@
doctype html doctype html
html(ng-app='freecodecamp') html(ng-app='profileValidation')
head head
script(src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js") script(src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js")
script(src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.8/angular.min.js") script(src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.8/angular.min.js")