How to Load Partial View first before Javascript

Posted in General by Marvin Mon Nov 02 2015 06:54:15 GMT+0000 (Coordinated Universal Time)·2·Viewed 2,199 times

Hi, I'm trying to integrate Angular with our existing application that have several jquery scripts on it. What I wanted to do is load the Partial View first before it execute the javascript from the Lazy Loading. (function () { var app = angular.module("app"); app.config(['$routeProvider', '$controllerProvider', function ($routeProvider, $controllerProvider) { app.registerCtrl = $controllerProvider.register; $routeProvider .when('/', { templateUrl: "welcome.html", resolve: { lazy: ['$ocLazyLoad', function ($ocLazyLoad) { return $ocLazyLoad.load([{ name: 'app', files: ['/js/Welcome.js'] }]); }] } }) .when('/two', { templateUrl: "views/page2.html" }) .when('/three', { templateUrl: "views/page1.html" }).otherwise({ redirectTo: '/' }) }]); })(); I'm not sure on how to do this. Many thanks
Nov 2, 2015

You want "welcome.html" to be loaded before "'/js/Welcome.js" ?
ocLazyLoad only loads the component into angular but doesn't execute them. The execution depends on your code (calling a service, a controller, ...).

Nov 3, 2015

Hi Olivier,

The Welcome.js contains jquery scripts that manipulate welcome.html ( e.g dataTables). I still dont have time to convert them to angular though. so I'm just thinking to utilize them for now. Basically the welcome.js is not a controller nor a service.

Markdown is allowed