Load controller dynamically in AngularJS

If you are using routing in AngularJS then It’s very important to load controller dynamically. Otherwise, you have to load all controllers at the beginning which is not efficient.

We can load controller dynamically by resolve attribute of $routeProvider
.when function. Please have a look on sample code. Surely, You will understand that.

var app = angular.module ('hw',['ngRoute','ngResource']);
app.config(['$routeProvider', '$controllerProvider', function($routeProvider, $controllerProvider) {
app.registerCtrl = $controllerProvider.register;

function loadcontroller(controllerSubPath){
$.ajaxSetup({async:false});
$.getScript("scripts/controllers/" + controllerSubPath + ".js").done(function( script, textStatus ) {
}).fail(function( jqxhr, settings, exception ) {
console.log( exception );
});
}

$routeProvider
.when('/Rights',{templateUrl:'views/Right/search.html', controller:'SearchRightController', resolve: { load: function () {loadcontroller("right/searchRightController");}}})
.otherwise({
redirectTo: '/'
});
}])
Advertisements

Hard Working & Commitment matter

Eager to learn new things, facing problem are key to development power. Hard working, Dedication, Commitment can ship great product. Listening others, accepting different views, ideas can increase creativity. Helping mind can sharp knowledge. Small small idea can bring another idea. Exploring new things open new door of opportunity. Over the 5 years of software development experience, Now I feel these.

 

As a Software engineer, I worked several platform. I believe, platform depends on project and personal choice. I worked in Java, .Net, Php. Interestingly, now-a-days most of the platform following same pattern and trends. That’s why, It’s very easy to adapt with new technologies.

 

Earlier In my career, I worked web development where server side component used like JSF, JSP etc. Now, AngularJS won developers heart. Because, client side should not depend on server side. Seriously, Restful API is responsible for more cutting edge, excellent web application project.

However, I always believe faith is key of success. At the same time, Hard working and strong commitment can bring success with faith.

 

I want to engage some exciting project where I can meet gig people. Toptal is great place to work on exciting project. I want to be a part of  Toptal community.

 

How to press any key automatically using batch program by opening existing user running application

Pressing any key automatically using batch program by opening existing user running application are given below:

Suppose your application is running in windows OS. Your need is to open application and press Ctrl+F to find something automatically by batch program. Then you can follow the instructions are given below

1. Create a VB script file named like “program.vbs”. Write following code and save it

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "notepad"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "^s"

where “notepad” is Notepad application which is already running. “WshShell.SendKeys” is using to keypress dynamically.

2. Create a batch file named like “auto.bat” and write following code and save it

wscript "F:\Ict_Backup\Desktop\program.vbs"

3. Run the batch file. See what happens.

Find more key code for vb script:

Key Code
Break {BREAK}
Backspace {Backspace}, {BKSP} or {BS}
Delete {DELETE} or {DEL}
Down Arrow {DOWN}
End {END}
Enter {ENTER} or ~
Escape {ESC}
Help {HELP}
Home {HOME}
Insert {INSERT} or {INS}
Left Arrow {LEFT}
Num Lock {NUMLOCK}
Page Down {PGDN}
Page Up {PGUP}
Print Screen {PRTSC}
Right Arrow {RIGHT}
Scroll Lock {SCROLLLOCK}
Tab {TAB}
Up Arrow {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
Alt {%}
Ctrl {^}
Shift Lock {+}

For example to specify CTRL and C, the code would be object.SendKeys “^C” and for SHIFT F5 object.SendKeys “+{F5}”. To specify multiple combination sets such as ALT A Z, you use parentheses, for example, object.SendKeys “%(AZ)”.