1

I tried to convert string variable to html with angular, I get $compile component suggestion but something went wrong

My controller:

ChatZamba.controller("ScriptController", ['$scope', '$compile', function ($scope, $timeout, $compile) {

And My angular function:

function build_step_view(data, i){
    if(data != undefined){
        var tmp = $compile($('.detail-script-list'))(scope);
        $('.detail-script-list').append(tmp);
    }
}

But I get TypeError: $compile is not a function in Chrome complier when triggered my function.

Help me! Thanks!

0

1 Answer 1

1

The controller code should be like:

ChatZamba.controller("ScriptController", ['$scope', '$timeout', '$compile', function ($scope, $timeout, $compile) {
}

You forgot to inject the reference of the $timeout service.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.