I am learning Angular JS
Here is my app.js
.when('/forget', {
title: 'forget',
templateUrl: 'resources/views/forget.php',
controller: 'genCtrl'
})
.otherwise({
redirectTo: '/login'
});
I want to display the forget.php
file inside resources/views
folder
Here is my genCtrl
app.controller('genCtrl', function ($scope, $rootScope, $routeParams, $location, $http, Data) {
//initially set those objects to null to avoid undefined error
$scope.forget = function ()
{
return 1;
}
});
When ever i do http://localhost/myapp/#/forget
the browser is displaying the content of forget.php
and then suddenly taking me to /login
.
How can i remain in the same page ?
Update :
Here is my app.js
Here is my genCtrl.js
Here is the console
Inspite of writing return '1', please write alert('test') and check the prompt message 'test' and this will not throw you in login page.
AngularJS will invoke the controller with a $scope
object. $scope
is the application object (the owner of application variables and functions), to know more about these services please check this link OR example.
PS: If this stuff helps you please leave me a comment and support :)
Thanks!