Angular Flashcards
Using model variable in HTML
{{name}}
- if name is updated in input field, its value is displayed immediately on the html page.
Using expression in HTML
{{expression}}
Form validation
When angular validates forms, standard HTML validation should be switched off with form:novalidation attribute.
form.FormController
Keeps track of all its controls and nested forms as well as the state of them, such as being valid/invalid or dirty/pristine.
$scope
Use in controllers. Access variables in HTML through this object. For example, $scope.name, etc.
- This is how you can alter the content of the page.
gTrack.controller(‘ControllerName’, function($scope) {});
$scope.$on
Execute function when a specific event occures.
$scope.$on(‘$viewContentLoaded’, )
Execute function when the view has been loaded.
$location
A service. Sets/gets the url in te browser. So, good for redirecting.
$rootScope
Available for all views.
- Problematic memory wise, use as little as possible
Execute something when an event happens
$rootScope.$on(‘event name’, function() )
Watch for changes a user variable
$scope.$watch ‘variable’ ->
do something
Parameters in URL-s: in HTML
ng-href=”#/checkins/{{a}}/{{b}}”
Parameters in URL-s: in route
/checkins/:a/:b
Parameters in URL-s: in controller
use $routeParams service
keyAt
Returns the Firebase key for a record in the array.
- accepts either an array index
- or a reference to an item that exists in the array