together
- Pull down this repository
- Check out what it is
- Add
ng-modelto the username<input>field
- give it a value of "username"
- Do the same for password
on your own
- Create a new
<div>immediately after the<form>element - Give it classes of
wellandcol-md-6
- aren't well's cool?
- Put in a couple of
{{ expressions }}forusernameandpassword
together
- Create a Controller with the name "FormController" in the app.js file
- Attach the Controller using
ng-controllerto the<div>parent of the<form> - Create an initial value for
usernamefrom within the Controller js code
- inject the
$scopeservice into your controller - set
$scope.username = "something";
together
- Attach a new function to the
$scopeservice called "login"
$scope.login = function(){ ... };
- Add a
console.login there to let us know it's being hit - Create an
ng-submiton the<form>and give itlogin() - Try it out
together
- Change what's in the
ng-controllerto:ng-controller="FormController as vm" - Assign
var vm = this;in your Controller js - Attach each of the variables there to the
vmobject - Change all variables in the
FormControllerto be values on thevmobject
- username
- password
- submit()
- Now don't ever use
$scopefor variables or custom functions again!
on your own
- Remove the initialization of
usernamein the Controller's js, that's silly - Make sure both of the fields are filled in using the
requiredattribute - Create an array for
loginson thevmobject - When someone logs in, add the username and current time to the
loginsarray console.logtheloginsarray- Clear the values of
usernameandpasswordwhen submitted
on your own
- Remove the expressions on the right of the form, we don't need them
- Instead, use
ng-repeatto output theloginsarray to thatwell;)
together
- Install
angular-mockswithbower - Clear the current specs.js file
describethe controllerbeforeEachtest, register the module
beforeEach(angular.mock.module('logintrest'));- note: angular-mocks registers
moduleon the global scope as well
- Try to run a dummy test
- Fix Karma
- angular-mocks depends on angular, so angular needs to be loaded first with Karma
together
- Add a new var
formControllerto thedescribes scope - Add the following
beforeEachafter the other one:
beforeEach(angular.mock.inject(function($controller){
formController = $controller('FormController');
}));
together
- Create a describe for
login() - Create an
itfor "should clear the values of username and password"
- set the values of
formController.usernameandformController.password - launch the
login() expectthem to be blank
on your own
- Figure it out!
on your own
- Use
ng-click - Remember the ng-repeat syntax that lets you get the index?
ng-repeat="(key, value) in array"
on your own
- Set up the
loginsarray - Test to see if it removed one