Copy var m1 = angular.module('myApp',[]);
m1.directive('hello',function(){
return {
restrict:'E',
replace:true,
transclude:true,
controller:function($scope){
this.name='niefee,hello';
},
template:'<div>nihao,<h1 ng-transclude></h1></div>'
};
});
m1.directive('hi',function(){
return {
restrict : 'E',
replace : true,
require : '?^hello',
template : '<span>hi angular</span>',
link:function(scope,element,attr,reController){
console.log(reController.name);
}
}
});
Copy <hello>
<hi></hi>
</hello>
Copy /*$http({
method:'GET',
url:'data.php',
}).success(function(data,state,hesders,config){
console.log(data);
console.log(state);
console.log(hesders);
console.log(config);
}).error(function(data){
document.write(data);
})*/
$http.get('data.php').success(function(data,stata,headers,config){
console.log(data);
})
Copy //var a = $location.absUrl();
$location.path('aaa/bbb/ccc').replace();
$location.hash('hello');
//$location.search({'age':'20'});
var a = $location.port();
//var a = $location.protocol();
console.log(a);
Copy <script>
var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope','$location','$anchorScroll',function($scope,$location,$anchorScroll){
$scope.change = function(id){
//console.log(id);
$location.hash(id);
$anchorScroll();
};
}]);
</script>
<div id="parent" ng-controller="Aaa">
<ul>
<li ng-repeat="id in [1,2,3,4,5]" ng-click="change('div'+id)">{{id}}aaaaaaaaaa</li>
</ul>
<div ng-repeat="id in [1,2,3,4,5]" ng-attr-id="div{{id}}">{{id}}</div>
</div>
Copy var para=document.createElement("p");
var node=document.createTextNode($scope.arr[i]);
para.appendChild(node);
Copy var parent=document.getElementById("div1");
var child=document.getElementById("p1");
parent.removeChild(child);