2

I have a problem which I have recently found myself obsessed with, see, I extreamly Now need you to show me the way of working the problem out.

My business task was to create a list of posts with comments to each of them.
Each post have 3 state: view, edit and deleted.

I’ve created directives Post and Comment. I’ve also created PostList and CommentList directives to manage Posts and Comments.
Post and Comment are similar code:
http://plnkr.co/edit/k77kdSwPnqY4jR5EY7N4?p=preview

app.directive("Post", function ($templateCache, $compile) {
    function getTemplate(mode) {
        switch (mode) {
            case "create":
                return "createPost.html";
            case "view":
                return "viewPost.html";
            case "delete":
                return "deletePost.html";
        }
    }

    var defaultMode = "view";

    return {
        scope: {},
        restrict: "AE",
        compile: function (elem, attrs, transclude) {
            return function ($scope, $element, $attr) {
                function updateTemplate() {
                    $element.html("");
                    $compile($templateCache.get(getTemplate($scope.mode)).trim())($scope,   function (clonedElement, scope) {
                        clonedElement.appendTo($element);

                    });
                }

                $scope.mode = $attr.mode || defaultMode;

                $scope.$watch("mode", updateTemplate);
            }
        }
    }
})

Each of templates (e.g. viewPost.html) have a lot of bindings and directives such as ng-show, ng-src, ng-bind-html-unsafe.
The viewPost.html contains commentList directive which responsible for displaying list of comments.
When I compile a Post the compilation of each comment for this post are launching automatically.

Here is the tree of directives:
Tree of directives

When I want to render a list of 20 posts with several comments to each of them, I’m waiting for more than a second before the work is done. Web page don’t response while this period.

Is my way correct to organize such structure?
Is Angular suitable for this business task?

I do love Angular, but now I feel upset and I’m afraid that Angular isn’t a good choice for this task.

Please, help me to bring back my hope and truly love to Angular. Tell me what I made wrong.

Here is my project which I really want you to look at:
http://vokruge.com/signin

login: [email protected]

pass: 123456

Be aware that’s all in Russian. You can visit this page to see how slow it is right now: http://vokruge.com/feed/280 .