Advertisement
Guest User

Untitled

a guest
May 25th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.88 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3.     <head>
  4.         <title>test</title>
  5.         <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js"></script>
  6.        
  7.         <script>
  8.             var app = angular.module('Test', []);
  9.            
  10.             app.controller('TestController', function ($scope) {
  11.                 $scope.onSelected = function () {
  12.                     console.log('onSelected', arguments);
  13.                 };
  14.             });
  15.            
  16.             app.directive('myFoo', function () {
  17.                 return {
  18.                     restrict: 'E',
  19.                     template: '<button type="button" ng-click="testFunc(47)">Test</button>',
  20.                     scope: {
  21.                         selected: '&'
  22.                     },
  23.                     controller: function ($scope) {
  24.                         $scope.testFunc = function (x) {
  25.                             console.log('testFunc', x);
  26.                             $scope.selected(x);
  27.                         };
  28.                     }
  29.                 };
  30.             });
  31.         </script>
  32.     </head>
  33.     <body ng-app='Test'>
  34.         <div ng-controller='TestController'>
  35.             <my-foo selected='onSelected' />
  36.         </div>
  37.     </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement