Your ng-click="showMoreInfo()" isn't firing because the ng-click directive isn't being compiled (angular is totally unaware of it) so the click behavior is never fired.
You want to read up on the $compile service if you're going heavy on dynamic content with angular directives.
Here's a plunkr that demonstrates $compile and why your code isn't working.
Here's the script from the demo plunk. The "win" directive correctly handles changes to the DOM, and the "fail" directive does not.
app = angular.module("app", [])
.controller("myController",function($scope) {
$scope.showMoreInfo = function() {
alert("Win Moar!");
}
})
.directive("win", ['$compile', function($compile) {
return {
restrict: "E",
scope: {
appendToId: "@",
},
template: "<button ng-click='click()'>ng-click's Inserted From Here Wins!</button>",
link: function(scope, elem, attrs) {
scope.click = function() {
let target = angular.element(document.querySelector("#" + scope.appendToId)),
content = target.html()
;
content += ("<p><span ng-click='showMoreInfo()' class='show-more-info'>...more</span></p>");
target.html(content);
/**
* The $compile service compiles an HTML string or DOM into a
* template and produces a template function,
* which can then be used to link scope and the template together.
*
* Because the html of target is compiled it's directives are going
* to get compiled, namely ng-click='showMoreInfo()'
*
* Note the passing target.scope() instead of scope...
*/
$compile(target)(target.scope());
}
}
}
}]).directive("fail", function() {
return {
restrict: "E",
scope: {
appendToId: "@",
},
template: "<button ng-click='click()'>ng-click's Inserted From Here Fail :(</button>",
link: function(scope, elem, attrs) {
scope.click = function() {
let target = angular.element(document.querySelector("#" + scope.appendToId)),
content = target.html()
;
content += ("<p><span ng-click='showMoreInfo()' class='show-more-info'>...more</span></p>");
/**
* Changing the DOM doesn't cause angular to process changes
* e.g. compile directives like ng-click so the ng-click in
* the content doesn't work.
*/
target.html(content);
}
}
}
})
As an aside, it is generally considered bad practice to perform DOM manipulations from controllers.