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
| // ng-include templates | |
| require('angulartemplate!./foo/bar/includedtemplate.html'); | |
| require('angulartemplate!./foo/bar/anotherincludedtemplate.html'); | |
| // and so on |
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
| angular.module('app') | |
| .component('myComponent', { | |
| templateUrl: 'foo/bar/myComponent.html', // OLD WAY | |
| controller: function(){ | |
| //controller code | |
| } | |
| }); | |
| angular.module('app') |
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
| var foo = {}; | |
| Object.defineProperty(a, "bar",{ | |
| get: getFoo, | |
| set: setFoo | |
| }); | |
| export default foo; | |
| function getFoo(){ | |
| //do shiz |
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
| angular.module('app').factory('myService', function($q, $http){ | |
| var data; | |
| var dataPromise; | |
| return { | |
| getData: getData | |
| } | |
| function getData(){ | |
| //If the data is already here, return it in a resolved promise |
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
| var x = "INIT"; | |
| function test(a = x) { | |
| var x; | |
| return a; | |
| } | |
| console.log( test() ); //undefined or 'INIT' | |
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
| <!--Pre-Angular 1.3--> | |
| <p id="normal-binding-example">Normal binding: {{name}}</p> | |
| <!--Angular 1.3--> | |
| <p id="one-time-binding-example">One time binding: {{::name}}</p> |
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
| //I don't think that this is working right in Firefox | |
| let c = let (a = getA()) a; | |
| console.log(c, a); //Logs 1, 0 | |
| //Why did it log 0 for "a"? | |
| function getA(){ | |
| return 1; | |
| } | |
| function getB(){ | |
| return 2; |
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
| let a = 0; | |
| { | |
| console.log(a); //Node throws error cause "a" isn`t defined yet, but it was defined on line one. | |
| let a = 1; | |
| console.log(a); | |
| } | |
| console.log(a); |
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
| var a; | |
| console.log(a); //Logs 'undefined' | |
| console.log(b); //ReferenceError: 'b' is not defined | |
| /** | |
| * Neither are defined, but only the undeclared variable gets an 'undefined' error. | |
| * | |
| * So, is the correct idiom 'undeclared' when referring to an instruction that will throw | |
| * a ReferenceError because it wasn`t declared? Or is there another idiom that I should use? | |
| * |
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
| angular.module('app').run(function($q, $timeout){ | |
| function User(data){ | |
| if(this == window)return new User(data); | |
| angular.extend(this, data); | |
| } | |
| User.prototype.sayHi = function(){ | |
| console.log("HI!!!"); |