JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="MyApp">
<div ng-controller="MyController">
<editkeyvalue accept="blabla()" key='keyA' value='valueA' />
</div>
</div>
JavaScript
var myApp = angular.module('MyApp',[])
myApp.directive('editkeyvalue', function() {
return {
restrict: 'E',
replace: true,
scope: {
accept: "expression"
},
template : '<div><label class="control-label">{{key}}</label>' +
'<label class="control-label">{{key}}</label>' +
'<input type="text" ng-model="value" />'+
'<button type="button" x-ng-click="cancel()">CANCEL</button>' +
'<button type="submit" x-ng-click="save()">SAVE</button></div>',
controller: function($scope, $element, $attrs, $location) {
$scope.save= function() {
$scope.accept();
};
}
}
});
myApp.controller('MyController', function($scope, $window) {
$scope.keyA = 'AA';
$scope.valueA= 'BB';
$scope.blabla = function() { $window.alert('hello') };
});