As a newcomer to AngularJS, I'm puzzled by why the code below isn't functioning as expected. The browser is not loading the file 'myjavascriptcode.js'. When I place
"<script src="./myjavascriptcode.js"></script>"
before importing Angular, the 'myjavascriptcode' file loads but triggers an 'angular is not defined' exception. Surprisingly, the only workaround that seems to make it work is placing
"<script src="../../angular-1.5.8/angular.js"></script>"
before the HTML tag.
jsdemo.html
<!DOCTYPE html>
<html>
<head>
<title>To do</title>
<script src="../../angular-1.2.5/angular.js" />
<script src="./myjavascriptcode.js"></script>
</head>
<body>
This is a simple example
</body>
</html>
./myjavascriptcode.js
function printMessage(unknownObject){
if( angular.isFunction(unknownObject) ){
unknownObject();
}else{
console.log("mi hai passato una variabile not function");
}
};
var variable1 = function sayHello(){
console.log("Hello");
}
var variable2 = "GoodBye!";
printMessage(variable1);
printMessage(variable2);
enter code here