1
People have problems when I insert one HTML containing a module ng, and when I click to run nothing happens. See Code:
//HomeCtrl.js
module.exports = function($scope) {
    // Create Note
    $scope.create = function(e) {
        var value = $scope.inputNote,
            $element = $(e.target).closest('.task-container').find('.tasks-list');
        $element.prepend(
            ' <li class="task-item"> '
                + '<div class="task-check">'
                    + '<label>'
                        + '<input type="checkbox">'
                        + '<span class="text"></span>'
                    + '</label>'
                + '</div>'
                + '<div class="task-state">'
                    + '<span class="label label-orange">ATIVA</span>'
                + '</div>'
                + '<div class="task-time">'
                    + '<a class="btn btn-sm btn-danger" href="#!" ng-click="remove($event)"><i class="fa fa-trash"></i> Remover</a>'
                + '</div>'
                + '<div class="task-body">'+ value +'</div>'
            + '</li>'
            );
    };
    // Button Remove
    $scope.remove = function(e) {
        var $element = $(e.target).closest('li');
        $element.remove();
    };
};
when I type in a input and from a ENTER, it sends to the ng-submit="create($event)" and executing the insertion of the HTML, the problem is the button  that has the function ng-click="remove($event)" and does not perform.
+1. I remember when I had struggled to discover this :\
– Wallace Maxters
I liked it when you said
$compile, but I noticed in the research that it is applied in adirectiveand not in thecontroller, when I executed the changes happened this mistake:Error: [ng:areq] Argument 'scope' is required– iLeonardo Carvalho
@iLeonardoCarvalho Correto, I forgot to add a parameter to the end. Reply corrected, thank you for mentioning the error!
– OnoSendai
It worked properly, now the
ngis recognized, but it is correct I insert aHTMLin thecontrolleror some examples talking to insert intodirective? 'Cause I can see how to convert thiscontrollerfor adirectivebut I want to apply to good programming practices.– iLeonardo Carvalho
@iLeonardoCarvalho If you are a Unit of work well defined, worth isolating in a directive. If not, don’t worry about it so much; one of the controller’s assignments is to coordinate the content display.
– OnoSendai
@Onosendai I will check this subject addressed, in this scenario is only the insertion of a
HTMLand the removal of the element built by aui-routerand modularizing the code using thebrowserify, I believe that it is still too little for a complex system but thank you for pointing out the article.– iLeonardo Carvalho