Cannot make angular app within meteor patterns

Unable to make angular app run in meteor patterns

here is my index.html

<body>
</body>

<template name="myIndex">
    <section ng-app="myApp" ng-controller="AppController as app">
        <div ng-include="'client/index.ng.html'"></div>
    </section>
</template>

and here is my index.js

MyIndexRouteController = PreloadController.extend({
    'preload': {
        'async': ['/js/xxx.js']
     },
});


Router.route('/', {
    template: 'myIndex',
    data: {
        env: 'someEnv',
        assets: ''
    },
    controller: MyIndexRouteController,

});

After running the router rules and the template in the rendered HTML, the angular directives do not start, not ng-app, rather than ng-include.

How can this be solved?

+4
source share
2 answers

Try https://docs.angularjs.org/api/ng/function/angular.bootstrap to start angular manually after the meteor pattern is rendered.

Angular ng-app, .

+1

, angular DOM.

-, :

MyIndexRouteController = PreloadController.extend({
    'onAfterAsync' : function() {
        //angular.element(document).ready(function() {
          angular.module('myApp', []);
          angular.bootstrap(document, ['myApp']);
        //});
    },
    'preload': {
        'async': ['/js/xxx.js']
     },
});
0

Source: https://habr.com/ru/post/1610901/


All Articles