0

I have created this html element using php :

 echo
     "<button 
      type ='button' class='login-btn login' 
      onclick = 'location.href='#!login';'> 
            Login
      </button>";

and when I click on it I want to get redirected to a login page using angularJS . If it is a regular html element it works succesfully but since I modify the '' , " " to create it with php my link does not work .

I get the error :Uncaught SyntaxError: Unexpected end of input for location.href

This is my angularJS file for a more detailed view :

angModule.js

const app = angular.module("myApp" , ["ngRoute"]);

app.config(($routeProvider)=>{
  $routeProvider
    .when("/" , {templateUrl:"main.php"})
    .when("/login" , {templateUrl : "login.php"})
    .when("/register" , {templateUrl : "register.php"});
});

I would appreciate your help .

0

1 Answer 1

1

You need to change the quotes in onclick = 'location.href='#!login';':

echo
     "<button 
      type ='button' class='login-btn login' 
      onclick = 'location.href=\"#!login\";'> 
            Login
      </button>";

(The first quote from '#!login' terminates the one from 'location.href=)

More on PHP strings: https://www.php.net/manual/en/language.types.string.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.