Using jquery mobile external page with a angular js controller

218 Views Asked by At

Hello im working on a web app project, and we are using jquery mobile for the pages ui and angular for mvc reasons,

Im having a problem using my external pages ( pages that ive load to my index.html), they dont recognize my controllers (only works the controllers that ive put in the index.html)

ill some of my code here to explain my problem

if ive put some angular values in my external page (previews declaration of the controller in my <div data-role="page" id="ResEjecSuc" class=".paginas" data-dom-cache="true" ng-controlles="categController" >

)

<span ng-class="sucursal.TIT_CATEGORIZACION">
                        {{sucursal.TIT_REALIZADA}}</span>

my app only shows: {{sucursal.TIT_REALIZADA}}

my controller init code :

app = angular.module('nevadaProt', [])
app.controller('categController', controlerCateg)

controlerCateg = function($scope, $locale) {
var sucursal = {
TIT_CATEGORIZACION:4,
TIT_REALIZADA:12
}

how ive load and after that transition to my html page: Load:

$.mobile.pageContainer.pagecontainer("load",
            "pages/RappidApps2/ResumenEjecZona.html", {});

transition:

$.mobile.pageContainer.pagecontainer("change", "#ResEjecSuc", {
        transition : "pop",
        reverse : false
    });

how can i make work angular controllers and external jquery mobile pages?

1

There are 1 best solutions below

0
André Claudino On

Once you are using Angular, you may create a directive.

app.directive('externalHtml', function(){
    return {
         restrict : 'E'
        ,replace : true
        ,templateUrl : 'pages/RappidApps2/ResumenEjecZona.html'
    };
});

then, you html should be something like:

<body>
    <div data-role="content">
        <external-html/>
    </div>
</body>

It always works for me.