All credits for STEPHEN GILBERT
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
| { | |
| // http://eslint.org/docs/rules/ | |
| "ecmaFeatures": { | |
| "binaryLiterals": false, // enable binary literals | |
| "blockBindings": false, // enable let and const (aka block bindings) | |
| "defaultParams": false, // enable default function parameters | |
| "forOf": false, // enable for-of loops | |
| "generators": false, // enable generators | |
| "objectLiteralComputedProperties": false, // enable computed object literal property names |
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
| // in this example the logged user data is a binded var in an angular controller | |
| // place code in a parent controller to run this code one time | |
| // any time this data change we should run this code again | |
| window.Intercom('update', { | |
| email: vm.user.email, | |
| user_id: vm.user.id, | |
| name: vm.user.first_name + ' ' + vm.user.last_name, | |
| last_login: vm.user.last_login, | |
| from_app: 'Office', // custom attr | |
| from_screen: $state.current.name, // custom attr |
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
| // service | |
| angular.module('myApp').service('request', ['$http', function($http) { | |
| var Request = function() { | |
| // Convenience helpers | |
| this.endpoints = { | |
| user: 'user', | |
| login: 'user/login' | |
| }; | |
| this.apiBase = 'http://myserver.com/api/'; |
When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.
-
Raw Attribute Strings
<div my-directive="some string" another-param="another string"></div>
When defining dependencies some prefixes are used.
"dependencies": {
"a": "~1.0.6",
"b": "^1.0.6",
"b": "*"
}
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
| // from a component controller | |
| toDataURL( | |
| image_url | |
| ).then( | |
| function onsuccess(response) { | |
| ctrl.ngModel.$setViewValue(ctrl.previousImage); | |
| }, | |
| function onError(response) { | |
| $log.error(response); | |
| } |