Last active
January 31, 2021 01:26
-
-
Save sbucek/10006299 to your computer and use it in GitHub Desktop.
[Titleee] asdasdasdasdasd
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 ng-app="app"> | |
<head> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js"></script> | |
<meta charset="utf-8"> | |
<title>Angular tips</title> | |
</head> | |
<body ng-controller="MainCtrl"> | |
<person header="header"> | |
<h2>{{header}}</h2> | |
<p person="person">Hello, I am {{person.name}} and,</p> | |
<p>I am a {{person.profession}}</p> | |
</person> | |
</body> | |
</html> |
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
angular.module('app', []) | |
.controller('MainCtrl', function($scope) { | |
$scope.person = { | |
name: 'John Doe', | |
profession: 'Fake name' | |
}; | |
$scope.header = 'Person'; | |
}) | |
.directive('person', function() { | |
return { | |
restrict: 'EA', | |
scope: { | |
header: '=' | |
}, | |
transclude:true, | |
template: '<div ng-transclude></div>', | |
link: function(scope, element, attrs) { | |
scope.person = { | |
name: 'Directive Joe', | |
profession: 'Scope guy' | |
}; | |
scope.header = 'Directive\'s header'; | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment