angularjsノート
2126 ワード
コンソールのデバッグelement($0).scope() $0~$4angular.element($("#controllerId")).scope()手動でangularを起動します.element(document).ready(function()/bodyのng-app="MyApp"angular.bootstrap(document.body,['MyApp'])})を以下の方法で削除できる場合.
ng-showの代わりにng-ifを使う
ng-classおよびng-styleは判断により付与する
ng-class="{'state-error':!data.isValid}"
統合js
依存注入
angualar.module('myModule', []). config(['depProvider', function(depProvider){ ... }]). factory('serviceId', ['depService', function(depService) { ... }]). directive('directiveName', ['depService', function(depService) { ... }]). filter('filterName', ['depService', function(depService) { ... }]). run(['depService', function(depService) { ... }]);
ng-showの代わりにng-ifを使う
ng-classおよびng-styleは判断により付与する
ng-class="{'state-error':!data.isValid}"
ngClass
ng-style=「{color:data.color='|data.name='活'?'#fff':':'#F 03 EF 0'}」統合js
var underscore = angular.module('underscore', []);
underscore.factory('_', function() {
return window._; //Underscore must already be loaded on the page
});
var myApp = angular.module("MyApp", ["ngSanitize", "underscore"]);
myApp.controller("TableCtrl", ["$scope", '_', function($scope, _) {
var init = function(){
console.log(_.keys($scope));
};
init();
}]);
依存注入
angualar.module('myModule', []). config(['depProvider', function(depProvider){ ... }]). factory('serviceId', ['depService', function(depService) { ... }]). directive('directiveName', ['depService', function(depService) { ... }]). filter('filterName', ['depService', function(depService) { ... }]). run(['depService', function(depService) { ... }]);