1

I am using angularjs and I want to create a simple registration page. I have used a link, so that when clicking on a link, the user should redirect to registration page.

I have got my index.html page like:

<!DOCTYPE html>
<html>
<head lang="en" np-app="login">
    <meta charset="UTF-8">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js" type="text/javascript"></script>
    <title>Test</title>
</head>
<body>
<a  href="#/partials/register.html">link</a>
</body>
</html>

and app.js like:

angular.module('login', [])
    .config(function ($routeProvider,$locationProvider) {

            $routeProvider.when('/register',
                {
                    templateUrl:    'partials/register',
                    controller:     RegisterCtrl
                });
            $routeProvider.when('/private',
                {
                    templateUrl:    'partials/private',
                    controller:     PrivateCtrl
                });
            $routeProvider.when('/admin',
                {
                    templateUrl:    'partials/admin',
                    controller:     AdminCtrl
                });

        });

when I click on 'link' hyperlink, it is not redirecting to register page.

My register page is something like:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Register</title>
</head>
<body>
<input type="text"/>
</body>
</html>
Flowdo
  • 57
  • 1
  • 1
  • 9
SA.
  • 732
  • 7
  • 20
  • 38

2 Answers2

1

If should work if you add target="_self" to the link. This bypasses angular routing mechanism.

See this thread.

Community
  • 1
  • 1
rhasarub
  • 41
  • 3
0

try to

templateUrl:    'partials/register.html',
                    controller:     RegisterCtrl

Add .html to your templateUrl

Flowdo
  • 57
  • 1
  • 1
  • 9