Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div ng-app='myApp' ng-controller='DirectiveTestController'>
- <button hello ng-click="testClick()">Test CLICK!</button>
- </div>
- var myApp = angular.module('myApp', []);
- myApp.controller('DirectiveTestController', ['$scope',
- function ($scope) {
- $scope.testClick = function () {
- window.alert("hey");
- console.log("hey");
- }
- }]);
- myApp.directive('hello', function () {
- return {
- scope: true,
- controller: ['$scope', '$element', '$compile', function ($scope, $element, $compile) {
- $element.removeAttr('hello');
- // $element.removeAttr('ng-click');
- $compile($element)($scope);
- }]
- };
- });
- app.directive("otcDynamic", function($compile){
- return {
- link: function(scope, element){
- var template = "<button ng-click='doSomething()'>{{label}}</button>";
- var content = $compile(template)(scope);
- element.append(content);
- }
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement