controllerAs: '$ctrl'
by default). Making the view still being bound to the $scope, but the controller exposed on the scope using $ctrl
(IIRC)
app.controller("testCtrl", ["$scope", "$log", function(a,b){}])
sliding-animation
to this ng-repeat-end
& ng-repeat-start
explicite dependency annotation using the inline bracket notation
.
dependency injection via an array
dependency injection via an arrray
the order of the parameters matter.
MyController.$inject = ["$scope", "$log"];
. This is also using an array but I call this: explicite dependency annotation using the $injector notation
@relentless-coder
also, anthony alicea's course on angularjs is really great. Learned for the first time that in case of
dependency injection via an arrray
the order of the parameters matter.
This is mentioned in the official docs aswell (tho maybe not in the most clear way, but it's there).
<div ng-repeat="item in itens" ng-animate="{enter: 'animate-enter', leave: 'animate-leave'}">...</div>
Hi guys, Im trying to use the $interval service to initiate a countdown, however, it seems my countdown is not working. I created a startCountdown function n to call it. Am I calling the service wrong?
var anghttp4 = angular.module('anghttp4', []);
anghttp4.controller ('MainController', function($scope, $http, $interval){
var onUserComplete = function(response){
$scope.user = response.data;
$http.get($scope.user.repos_url)
.then(onRepos, onErr);
$scope.success = "Successfully got user from Github!";
$scope.message = "alert alert-success";
};
var onRepos =function(response){
$scope.repos = response.data;
};
var onErr = function(whathappened){
$scope.error = "Could not get user data";
$scope.message = "alert alert-danger";
};
$scope.search = function(username){
$http.get ("https://api.github.com/users/" + username)
.then(onUserComplete, onErr);
};
$scope.username = "julianamariemorales";
$scope.countdown = 5;
//startCountdown();
$scope.startCountdown = function() {
$interval($scope.decrementCountDown, 1000,$scope.countdown);
};
$scope.decrementCountDown = function() {
$scope.countdown -= 1;
if ($scope.countdown < -1) {
$scope.search($scope.username);
}
};
/*
//$interval(fn, delay, [count], [invokeApply], [Pass]);
var decrementCountDown = function() {
$scope.countdown -= 1;
if ($scope.countdown < -1) {
$scope.search($scope.username);
}
$scope.startCountdown = function() {
$interval(decrementCountDown, 1000,$scope.countdown);
};
$scope.startCountdown();
};
*/
});
Thank you!
$scope.startCountdown();
before the module ends. Sorry I meant the countdown works but the automatic search that I want to happen when the countdown ends does not work. This part does not execute $scope.search($scope.username)
...
$scope.countdown
will never be lower then -1.
$scope.decrementCountDown = function() {
$scope.countdown -= 1;
if ($scope.countdown === 0) {
$scope.search($scope.username);
}
};
5
and next you subtract the value 1
from it for 5
times. 5-(5*1) = 0.
npm install
)
bower install -S karma or whatever is the name
this will update your package.json file automatically
npm install
npm install --save-dev karma jasmine
["foo", "bar", function(foo, bar) {...}]
injection style (according to the docs) is Inline Array Annotation.