Last active
December 26, 2015 17:08
-
-
Save allenyang79/7184622 to your computer and use it in GitHub Desktop.
test angular to parse @ attribute $eval and @parse
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
app=angular.module "app",[] | |
app.controller "Ctrl",($scope)-> | |
console.log "Ctrl start" | |
$scope.heroName="susus" | |
app.directive "hero",()-> | |
return { | |
restrict:"EA" | |
template:""" | |
<div>you are my {{heroName}}</div> | |
""" | |
link:(scope,elements,attrs)-> | |
console.log "hero" | |
console.dir attrs.skill | |
scope.skill=scope.$eval(attrs.skill); | |
console.log "parse" | |
console.dir scope.skill | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> | |
</head> | |
<body> | |
<div ng-app="app" ng-controller="Ctrl"> | |
<hero hreo-name="balabala" skill="{aa:'AA',bb:'BB'}"></hero> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment