Refactored dynamic script creating and started for angularjs