0

I have created a pop up using Dialog servce.

I am planning to show some message to user like this

    txt = '<ul> 
        <li data-ng-repeat = "eachValue in dummnyList" > 
           {{eachValue | applyFilter}}
        </li></ul>' ;

It is processing successfully but it considering {{eachValue | applyFilter}} as text.

  • {{eachValue | applyFilter}}

Am I missing any thing.

The complete code for pop up is

var txt = '<ul> 
            <li data-ng-repeat = "eachValue in dummnyList" > 
               {{eachValue | applyFilter}}
            </li></ul>' ;    
var proceedButton = {label:'Ok', result: 'ok', cssClass: 'btn blue-button', returnFunction: proceedFunction};
        var cancelButton = {label:'Cancel', result: 'not ok', cssClass: 'btn red-button', returnFunction:cancelFunction};
        var buttons = [];
        buttons.push(proceedButton);
        buttons.push(cancelButton);

        DialogUtils.openMessageBox({
            title: 'Note',
            message: txt,
            buttons: buttons
        });
Patan
  • 17,073
  • 36
  • 124
  • 198

2 Answers2

1

There's your problem. AngularJS does not know, that you added this code. You can use $compile to add code like in this question.

$('body').append($compile("<my-angular-directive />")(scope));
scope.$apply(); 

But you should think about getting rid of old jQuery and solving your problems completly with angular...

Community
  • 1
  • 1
Daniel
  • 3,541
  • 3
  • 33
  • 46
  • Thanks. Do you want to add compile like this txt = $compile(
    • {{eachValue | applyFilter}}
    ) ;
    – Patan Jul 03 '14 at 09:46
  • you need to add `'` quotes around your string, but indeed that should solve your problem: `txt = $compile('
    • {{eachValue | applyFilter}}
    ');`
    – Daniel Jul 03 '14 at 09:48
  • Thanks. I am new to angular js. DO I need to Inject this in angular module. I have this function in controller not in directive. – Patan Jul 03 '14 at 09:57
  • 1
    where is your jQuery code located? Do you perform the actions within the controller? Then you simply need to $compile the html markup befor edding it to the page. – Daniel Jul 03 '14 at 09:59
  • I am performing these actions in the controller. Will it be just enough to add txt = $compile('
    • {{eachValue | applyFilter}}
    ');
    – Patan Jul 03 '14 at 10:01
  • you need to add both lines: `txt = $compile('
    • {{eachValue | applyFilter}}
    ')(scope);` and `scope.$apply();`
    – Daniel Jul 03 '14 at 10:03
  • Thank you for helping me. I have edited the question. txt is html code. It would be great if you can post answer as per my code. That would really help me. – Patan Jul 03 '14 at 10:08
0

In angularJS you should not modify the template outside of directives. You should create a directive to create your pop-up. You could workaround and keep your jQuery habits but this is not the way AngularJS is supposed to work.

Pak
  • 2,123
  • 22
  • 28