Skip to content

Instantly share code, notes, and snippets.

@kalbarczyk
Created March 18, 2015 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalbarczyk/06f4f2bf85421469a8e4 to your computer and use it in GitHub Desktop.
Save kalbarczyk/06f4f2bf85421469a8e4 to your computer and use it in GitHub Desktop.
AngularJS - Zrozumieć require
<!doctype html>
<html data-ng-app="app">
<head>
<title>AngularJS - Zrozumieć require</title>
</head>
<body>
<div>
<input type="text" ng-model="text" placeholder="Wpisz text" />
<div wjs-require ng-model="text"></div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js"></script>
<script>
(function () {
'use strict';
angular
.module('app', []);
})();
(function () {
'use strict';
angular.module('app')
.directive('wjsRequire', wjsRequire);
function wjsRequire() {
return {
restrict: 'A',
require: '^ngModel',
template: '<div><h4>Text: {{ngModel}}</h4></div>',
scope: {
ngModel: '='
},
}
}
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment