[Angular] Isolate Scop &
2023-09-14 09:00:56 时间
<!DOCTYPE html> <html> <head> <title>Angular Directive</title> <link rel="stylesheet" href="foundation.min.css" /> <script src="angular.min.js"></script> <script src="main.js"></script> </head> <body > <div ng-app="photoApp"> <div ng-controller="photoCtrl" phone dial = "callHome(message)" pay = "makeLove(person)"></div> </div> </body> </html>
var app = angular.module("photoApp", []); app.controller("photoCtrl", function($scope){ $scope.callHome= function(message){ console.log("Call "+message+" sex service"); } $scope.makeLove= function(person){ console.log("ask "+person+" come make love with me"); } }); app.directive("phone", function() { return { scope: { dial: "&" , pay: "&" //can pass obecjt to dial //pass object between controller and directive }, template: '<input type="text" ng-model="value"><div class="button" ng-click="dial({message:value})">Call Home</div>'+ '<input type="text" ng-model="name"><div class="button" ng-click="pay({person:name})">make love</div>' } });
相关文章
- 微信小程序&mpvue问题总结(1)
- [Angular 2] More on *ngFor, @ContentChildren & QueryList<>
- [Servlet&JSP] HttpSession会话管理
- Apache Spark源码走读(八)Graphx实现剖析&spark repl实现详解
- [Angular HTML] Overwrite input value, String.fromCharCode & input.selectionStart
- [Angular 2] Value Providers & @Inject
- [Angular 2] @Input & @Output Event with ref
- [Angular 2] ng-control & ng-control-group
- PG&GP · 特性分析 · 外部数据导入接口实现分析
- Shiro之UsernamePasswordToken&RememberMeAuthenticationToken&AuthenticationToken
- Dijkstra's Algorithm
- C++:C++编程语言学习之逻辑控制语句(循环语句&判断语句)&异常处理(try-catch-throw)的简介、案例应用之详细攻略
- 翻翻git之---"有趣效果"的自己定义View EasyArcLoading
- 线段树区间更新,区间统计+离散化 POJ 2528 Mayor's posters
- 技术专家或技术领导人所需具备的综合素质 / By 禅与计算机程序设计艺术&GPT-4
- C#为null或Empty && &
- hdu 3966 Aragorn's Story(树链剖分+树状数组)
- OpenCV入门(九)快速学会OpenCV8漫水填充floodFill&ROI
- 【Web开发】Vue2.0数据去重&Element-UI单选框