This file contains hidden or 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.$emit('post.test', {method : 'getUser', userid:'myid', password:'mypw'}); // cache:false | |
$scope.$on('post.success', function () { | |
console.log('POST OK.'); | |
}); | |
$scope.$on('post.error', function () { | |
console.log('POST fail server!'); | |
}); |
This file contains hidden or 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('httpService', ['$http', '$rootScope', function ($http, $rootScope) { | |
var service = {}, | |
name; | |
const GATEWAY = 'http://localhost:3000/'; | |
const CFGATEWAY = 'http://localhost:8501/angular/gateway.cfm'; | |
$rootScope.$on('post.test', function (event, data) { | |
name = event.name; |
This file contains hidden or 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.run(['$injector', function ($injector) { | |
$injector.get('httpService'); | |
}]); |
This file contains hidden or 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('httpServiceInterceptor', ['$q', function ($q) { | |
return function (promise) { | |
return promise.then(function (response) { | |
return response; | |
}, function (response) { | |
return $q.reject(response); | |
} | |
); | |
}; | |
}]); |
This file contains hidden or 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
$httpProvider.responseInterceptors.push('httpServiceInterceptor'); |
This file contains hidden or 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
basePath = ''; | |
files = [ | |
JASMINE, | |
JASMINE_ADAPTER, | |
// 3rd-party | |
'app/scripts/vendor/angular.js', | |
// App-specific |
This file contains hidden or 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.directive('focus', function () { | |
return { | |
restrict: 'A', | |
link : function (scope, element) { | |
element[0].focus(); | |
} | |
} | |
}); |
This file contains hidden or 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
"AngularJS is what HTML would have been, had it been designed for building web-apps." | |
- templates (components) | |
- data-binding | |
- MVC | |
- dependency injection | |
- excellent testability | |
- client-side JavaScript | |
Links: |
This file contains hidden or 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
<!DOCTYPE html> | |
<html ng-app> | |
<head> | |
<title>My First Angular Application</title> | |
</head> | |
<body> | |
<input type="text" ng-model="inputVal" placeholder="Please enter your name" value=""/> | |
<br> | |
<span ng-show="inputVal.length > 0">Hello</span> {{inputVal}} |
This file contains hidden or 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('LoginCtrl', ['$scope', function ($scope) { | |
$scope.model = { | |
userName : '', | |
password : 'name' | |
}; | |
}]); |