JSFiddle - React, Tailwind, and code Playground
by cdparmeter
HTML
<div ng-app="MyApp">
<div ng-controller="MyController">
<container data-method="foo" />
</div>
</div>
JavaScript
var myApp = angular.module('MyApp', []);
myApp.directive('container', function () {
return {
restrict: 'E',
replace: 'true',
scope: {
methodToCall: '&method'
},
template: "<div>" +
"<input ng-model='textToPush'/>" +
"<button ng-click='pushText'>Push</button>" +
"<button ng-click='finish'>Finish</button>" +
"</div>",
link: function (scope, element, attrs) {
scope.paragraphs = [];
scope.pushText = function () {
scope.paragraphs.push(scope.pushText);
scope.pushText = "";
}
scope.finish = function () {
scope.methodToCall(scope.paragraphs)
}
}
}
});
myApp.controller('MyController', function ($scope, $window) {
$scope.foo = function (textArray) {
console.log(textArray)
};
});