Angular JS in combination with Mendix

1
Hi I am currently trying to implement a Angular JS component/code into my Mendix application and I am currently struggling to get it to work. Has anyone had experience in getting Angular to work alongside Mendix is there something that I have to do differently? I have used JQuery in combination with Mendix before and that was relatively straight forward. Regards
asked
1 answers
6

I setup it like this:

 postCreate: function() {
    var canvas = mxui.dom.div({'style' : 'height: '+ this.height+'px; width: 100%'});
    canvas.setAttribute("id",'messagebusdesigner');//set ID
    canvas.setAttribute("ng-controller", "busCtrl");
    this.domNode.appendChild(canvas);//add as node
    var messageBus=document.createElement('div');//create div for message bus
    messageBus.setAttribute("message-bus",'');//set attribute message-bus
    canvas.appendChild(messageBus);//append to main Div
    angular.bootstrap(canvas,['messagebus']);//bootstrap to messagebus module
    this.msgbusScope=angular.element(document.getElementById('messagebusdesigner')).scope();//get scope
    ...
},

Then in applyContext, you can set value to Scope

applyContext: function(context, callback) {       
    var scope=this.msgbusScope;   
    scope.$apply(function(){
        scope.setValue....;
    });
    callback && callback();
},
answered