This file contains 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
<label>Click here to submit buddy</label> | |
<input type="submit" | |
ng-click="doSomething() | trackEvent:'Home Category':'Button clicked'" /> |
This file contains 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
angular.module('sample-app', ['angularytics']) | |
.config(function(AngularyticsProvider) { | |
AngularyticsProvider.setEventHandlers(['Console', 'Google']); | |
}) | |
.run(function(Angularytics) { | |
Angularytics.init(); | |
}); |
This file contains 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
// Assigning promise | |
// GET /api/v1/users | |
var users = Restangular.all('users').getList(); | |
// GET /api/v1/users/123 | |
var user = Restangular.one('users',123).get(); | |
// Assigning value | |
// GET /api/v1/users | |
Restangular.all('users').getList().success(function(users) { |
This file contains 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
var userResource = $resource('/users/:userId', {}, { | |
getList: {method: 'GET', params: {}, isArray: true}, | |
get: {method: 'GET', params: {}, isArray: false}, | |
}); | |
var users = userResource.getList(); | |
var user = userResource.get({userId: 123}) | |
// Later in the code | |
var carResource = $resource('/users/:userId/cars/:carId', {}, { |
This file contains 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
module.directive('pie', function () { | |
return { | |
replace: true, | |
restrict: 'EA', | |
scope: {type: '@', data:'='}, | |
templateUrl: "/js/test/angular/partials/pie.html", | |
controller: ['$scope', '$routeParams', '$element', '$filter', function($scope, $routeParams, $element, $filter) { | |
$scope.$watch('data', function() { | |
if (_.isUndefined($scope.data) || _.isNull($scope.data) || $filter('isZeroData')($scope.data)) { |
This file contains 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
<div> | |
<h1>First Tab</h1> | |
<input type="text" ng-model="query.searchText" /> | |
<pie data="data.valuesData | forPie" type="valuesPie" /> | |
</div> |
This file contains 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
'use strict'; | |
/** | |
* Application start point. | |
* | |
* Note, we use minifyer, so all dependencies should be explicitly defined with ['<dependency>', | |
* function(<dependency>) {}]; | |
*/ | |
var module = angular.module('example', | |
[ 'restangular', 'ngResource']).config( |
This file contains 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
<html> | |
<head> | |
<!-- Include here Styles and AngularJS scripts--> | |
</head> | |
<body> | |
<div class="container" ng-app="example" ng-controller="MainCtrl" ng-cloak> | |
<header> | |
<div>This is the common headers for all of the tabs of this little app</div> | |
</header> | |
<!-- This is the div that will change when the URL changes via the $routeProvider--> |
This file contains 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
var buildings = Restangular.all("buildings").getList(); | |
// New promise after adding the new building | |
// Now you can show in scope this newBuildings promise and it'll show all the buildings | |
// received from server plus the new one added | |
var newBuildings = buildings.push({name: "gonto"}); | |
var newBuildingsSame = buildings.call("push", {name: "gonto"}); | |
// This is a promise of a number value. You can show it in the UI |
This file contains 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
function enhancePromise(promise, isCollection) { | |
promise.call = angular.bind(promise, promiseCall); | |
promise.get = angular.bind(promise, promiseGet); | |
return promise; | |
} | |
function promiseCall(method) { | |
var deferred = $q.defer(); | |
var callArgs = arguments; | |
this.then(function(val) { |