361 |
doesn't work
work
from:
http://stackoverflow.com/questions/17039926/adding-parameter-to-ng-click-function-inside-ng-repeat-doesnt-seem-to-work |
2015年11月27日 星期五
ng-click angularjs parameters problem
2015年11月26日 星期四
angularjs factory return problem null undefined
========== work =========
factory.getInit = function(type,lable){
var t=null;
angular.forEach(factory.models[type], function(value, key) {
if(value.lable == lable){
t=value.init;
console.log("getInit-value.init: "+t);
}
});
return t;
};
========== doesn't work =========
factory.getInit = function(type,lable){
angular.forEach(factory.models[type], function(value, key) {
if(value.lable == lable){
console.log("getInit-value.init: "+value.init);
return value.init;
}
});
};
2015年11月22日 星期日
wordpress The requested document was not found on this server.
problem fix my changing file attributes to writable
mysql GREAT data base superuser
# mysql -u SUPERUSER -p
GRANT ALL PRIVILEGES ON * . * TO 'USER1'@'localhost';
# mysql -u USER1 -p
mysql> create Database NEWDB;
2015年11月19日 星期四
angularjs date
https://docs.angularjs.org/api/ng/filter/date
<span ng-non-bindable>{{1288323623006 | date:'medium'}}</span>:
<span>{{1288323623006 | date:'medium'}}</span><br>
<span ng-non-bindable>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span>:
<span>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span><br>
<span ng-non-bindable>{{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}</span>:
<span>{{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}</span><br>
<span ng-non-bindable>{{1288323623006 | date:"MM/dd/yyyy 'at' h:mma"}}</span>:
<span>{{'1288323623006' | date:"MM/dd/yyyy 'at' h:mma"}}</span><br>
{{1288323623006 | date:'medium'}}: Oct 29, 2010 11:40:23 AM
{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}: 2010-10-29 11:40:23 +0800
{{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}: 10/29/2010 @ 11:40AM
{{1288323623006 | date:"MM/dd/yyyy 'at' h:mma"}}: 10/29/2010 at 11:40AM
2015年11月18日 星期三
angularjs , log in redirect ng-router
http://stackoverflow.com/questions/11541695/redirecting-to-a-certain-route-based-on-condition
'use strict';
var app = angular.module('app', [])
.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: "login.html",
controller: LoginController
})
.when('/private', {
templateUrl: "private.html",
controller: PrivateController,
resolve: {
factory: checkRouting
}
})
.when('/private/anotherpage', {
templateUrl:"another-private.html",
controller: AnotherPriveController,
resolve: {
factory: checkRouting
}
})
.otherwise({ redirectTo: '/' });
}]);
var checkRouting= function ($q, $rootScope, $location) {
if ($rootScope.userProfile) {
return true;
} else {
var deferred = $q.defer();
$http.post("/loadUserProfile", { userToken: "blah" })
.success(function (response) {
$rootScope.userProfile = response.userProfile;
deferred.resolve(true);
})
.error(function () {
deferred.reject();
$location.path("/");
});
return deferred.promise;
}
};
=========================angular.module('yoApp')
.service('appService', function ($q, $timeout, $rootScope, $location) {
this.isAdmin=function(){
console.log("isAdmin");
var deferred = $q.defer();
deferred.resolve(true);
// deferred.reject();
// $location.path("/about");
return deferred.promise;
}
});
.config(function ($routeProvider) {
$routeProvider
.when('/me', {
template: '<h1> me </h1>',
resolve: {
factory: function(appService) {
return appService.isAdmin();
}
}
})
});
2015年11月11日 星期三
angular js Dependency injection
https://www.airpair.com/angularjs/posts/top-10-mistakes-angularjs-developers-make
Dependency injection is one of AngularJS's best patterns. It makes testing much simpler
var app = angular.module('app',[]); app.controller('MainCtrl', function($scope, $timeout){ $timeout(function(){ console.log($scope); }, 1000); });
Here, it's very clear that
Dependency injection is one of AngularJS's best patterns. It makes testing much simpler
var app = angular.module('app',[]); app.controller('MainCtrl', function($scope, $timeout){ $timeout(function(){ console.log($scope); }, 1000); });
Here, it's very clear that
MainCtrl
depends on $scope
and $timeout
.angularness factory vs service
http://ithelp.ithome.com.tw/question/10161278
Service 是用 new 來建立的
Factory 的行為很簡單,Controller 注入Factory 取得的物件就是被 factory object ({}) 包起來並且 return 的物件。
也就是說,假如沒有被 { } 包起來值都不會被外面取得。
(p.s. 不一定要 return object, 任何 type 都可以)
Service 是把東西存在 this 裡面,像是我們平常在製作 constructor 一樣。
以上範例假如寫成 constructor 就會是
Service 是用 new 來建立的
Factory 的行為很簡單,Controller 注入Factory 取得的物件就是被 factory object ({}) 包起來並且 return 的物件。
也就是說,假如沒有被 { } 包起來值都不會被外面取得。
(p.s. 不一定要 return object, 任何 type 都可以)
Service 是把東西存在 this 裡面,像是我們平常在製作 constructor 一樣。
以上範例假如寫成 constructor 就會是
2015年11月10日 星期二
angular js $emit , $on
example
http://www.bennadel.com/blog/2723-unbinding-scope-on-event-handlers-in-angularjs.htm
$scope.$emit('name', 'args');
$scope.$broadcast('name', 'args');
2015年11月9日 星期一
2015年11月8日 星期日
angularjs complied order ,structure
http://stackoverflow.com/questions/20663076/angularjs-app-run-documentation
Here's the calling order:
app.config()
app.run()
- directive's compile functions (if they are found in the dom)
app.controller()
- directive's link functions (again, if found)
Here's a simple demo where you can watch each one executing (and experiment if you'd like).
From Angular's module docs:
============
very good example:
============
index.html:54 app config
index.html:50 app run
index.html:37 directive setup
index.html:39 directive compile
index.html:58 app controller
index.html:45 directive link
<script>
var myApp = angular.module('myApp', []);
myApp.factory('aProvider', function() {
console.log("factory");
});
myApp.directive("test1", function() {
console.log("directive setup");
return {
compile: function() {console.log("directive compile");}
}
});
myApp.directive("test2", function() {
return {
link: function() {console.log("directive link");}
}
});
myApp.run(function() {
console.log("app run");
});
myApp.config( function() {
console.log("app config");
});
myApp.controller('myCtrl', function($scope) {
console.log("app controller");
});
</script>
================
訂閱:
文章 (Atom)