Ej DEV
Ej DEV

Reputation: 202

How to load ajax partials on tabs by Angularjs

Is it possible to load nested partials with forms inside to the partial tabs such as:

<ng-include src="'form_group.html'"></ng-include>

Another issue is that the expressions {{}} are not binding to the actual output, am I missing something? I wanted to retain the two-way binding of the expression and scopes of the text partial contents in the Controller.

Plunkr Source code

Upvotes: 1

Views: 155

Answers (1)

Nidhish Krishnan
Nidhish Krishnan

Reputation: 20751

Try out this

PLUNKER

app.directive('bindHtmlUnsafe', function( $parse, $compile ) {
    return function( $scope, $element, $attrs ) {
        var compile = function( newHTML ) {
            newHTML = $compile(newHTML)($scope);
            $element.html('').append(newHTML);        
        };

        var htmlName = $attrs.bindHtmlUnsafe;

        $scope.$watch(htmlName, function( newHTML ) {
            if(!newHTML) return;
            compile(newHTML);
        });

    };
});

Upvotes: 1

Related Questions