Edit scope variable in ng-repeat
$loop = 20; // Number of times to connect to website | |
$url = "http://www.yoursite.com/"; | |
$start = microtime(true); | |
for ($i=1; $i < $loop; $i++) { | |
$lstart = microtime(true); | |
$f = fopen($url, 'r', 0); | |
$meta_data =stream_get_meta_data($f)['wrapper_data'][0]; |
Use ng-attr-your-attribute
to conditionally add or remove an attribute in HTML element.
AngularJS 1.3 above
Try out ng-options
inside ``
<?php | |
$condition = true; | |
$arr = array( | |
'a' => 'abc', | |
($condition ? 'b' : '') => ($condition ? '123' : ''), | |
($condition ? 'c' : '') => ($condition ? 'xyz' : ''), | |
); | |
$arr = array_filter($arr); |
<?php | |
$condition = true; | |
$arr = array( | |
'a' => 'abc', | |
($condition ? 'b' : '') => ($condition ? '123' : ''), | |
($condition ? 'c' : '') => ($condition ? 'xyz' : ''), | |
); | |
$arr = array_filter($arr); |
How to chain promises one after another for unknown amount of times? This example shows how chain $timeout
using .then()
Each $timeout
change the color of a block in a random delay time.
And each one happens one by one for dynamic number of times.
Creat a dynamic filter function for ngRepeat outside Angular controller scope
The filter function is run against a dynamically changed object.
http://jsfiddle.net/gh/gist/library/pure/6c6823e0600b707bce83/
<!--- Convert a ColdFusion variable to JSON format ---> | |
<cfset s = "I'm a string or URL."> | |
<cfset numInteger = 1994> | |
<cfset JSONUtil = createObject("component","functions.JSONUtil")> | |
<cfoutput>#JSONUtil.serializeJSON(s)#</cfoutput> | |
<cfoutput>#JSONUtil.serializeJSON(numInteger,0,1)#</cfoutput> | |
<!--- Read json ---> | |
<cfset strJson = ' {"strerror":"","strsuccess":"Thank you for your message!"}'> |
Define and resolve promises before running controller code in AngularJS
Putting $http promise into a service and then resolve it is recommended as it will load json sooner.
http://jsfiddle.net/gh/gist/library/pure/abb04b575636f820d1a3/