1: First say the command domain scope @
I think the description is very laborious, directly in the code to illustrate:
Angularjs.html
<!doctype html>
Main05.js
var myapp=angular.module (' myApp ', []); Myapp.controller (' Listctrl ', function ($scope) { $scope. logchore= " Motorola ";}); Myapp.directive (' Kid ', function () {return {' Restrict ': ' E ', Scope:{title: "@"},template: ' <div >{{title}}</ Div> '}});
Entering a number in the input box is bound to the title of the directive template.
2: Say more about scope =
angularjs.html
<!doctype html>
The Main05.js code is as follows:
var myapp=angular.module (' myApp ', []); Myapp.controller (' Listctrl ', function ($scope) { $scope. logchore= " Motorola ";}); Myapp.directive (' Kid ', function () {return {' Restrict ': ' E ', scope:{title: ' = '},template: ' <div >{{title}}</ Div> '}});
3: Finally say & This is used for method invocation.
The angularjs.html code is as follows:
<!doctype html>
The Main05.js code is as follows:
var myapp=angular.module (' myApp ', []); Myapp.controller (' Listctrl ', function ($scope) { $scope. logchore=function () { alert (' OK '); };}); Myapp.directive (' Kid ', function () {return {' Restrict ': ' E ', Scope:{flavor: ' & ' },template: ' <div >< Button ng-click= "flavor ()" ></button></div> '}});
If Logchore with parameters,The angularjs.html code is as follows:
<!doctype html>
The Main05.js code is as follows:var myapp=angular.module (' myApp ', []); Myapp.controller (' Listctrl ', function ($scope) { $scope. logchore=function (x) { alert (x); };}); Myapp.directive (' Kid ', function () {return {' Restrict ': ' E ', Scope:{flavor: ' & '},template: ' <div > < Input type= "text" ng-model= "V"/> <button ng-click= "flavor ({t:v})" ></button></div> '}});
ANGULARJS Learning Department (3) instruction @=&