ANGULARJS Learning Department (3) instruction @=&

Source: Internet
Author: User

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 @=&

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.