AngularJS - link to an anchor link on a different page - html

I'm wondering if someone could advise me... I am not very familiar with AngularJS but I am currently working on a site that uses it. I have several scenarios where I have to link to an anchor link on a different page/different url and if I was to simply put it as this for example:
Click here to view this link
It causes a 404. I have found several solutions for anchor links within the same page but nothing that works with AngularJS to link to an anchor link on a different page/url.
Can anyone help? Thank you.

Angularjs parses href's for redirection. It attempts to go to a view with anchorlink
Try setting this in your routes
// use the HTML5 History API
$locationProvider.html5Mode(true);
And om your html header, set a base location of your site with <base href="/">
This should make angularjs stop interfering with anchor tags in your urls.
EDIT
#Sabarish Senthilnathan's comment works also, probably the best way too.

Related

How to make an anchor working in a vaadin page?

I have a vaadin app which renders raw html into a vaadin layout.
The html includes a anchor and a href that points to the anchor.
The problem is that my page includes a path and a query:
https://onepub.dev/Blog?id=zhhnoflygz
This above link is to a live page so you can see it in action.
The target is written as:
<h1 id="how-to-resolve-the-problem">How to resolve the problem</h1>
The anchor is written as:
How to resolve the problem
When I hover over the anchor the browser shows:
http://onepub.dev/#how-to-resolve-the-problem
Looking at html documentation and examples it's my understanding that the anchor should show as:
https://onepub.dev/Blog?id=zhhnoflygz#how-to-resolve-the-problem
As it stands, when I click on the anchor it takes me to the sites home page rather than scrolling down to the section the anchor links to.
Is this a vaadin SPA problem or have I just mis-understood how anchors work?
The anchor works find in a html editor.
Edit:
After some research I've found that vaadin intercepts clicks to anchors.
You can surpress this by adding the 'router-ignore' attribute to the a tag.
hi
This however didn't solve my problem.
I then did a comparison by setting up a test using the w3schools tryit page.
There is a clear difference.
When I open the dev tools in chrome and hover over the 'a' link on my vaadin site it shows
When I look at a similar tag in w3schools:
The key difference is that w3schools shows the complete url which appears to be taken from 'window.location.href'
The vaadin page however seems to take the url form 'window.location.origin' even though window.location.href has the correct url including the path and query params.

Laravel routes and controllers not working

Good day All
I'm am working on my first laravel project and I ran into a problem that I cant seem to fix.
I have a few basic views, controllers, and routes that work together with a basic HTML navbar. The problem I am having is that when I click on the next page in my navbar it works fine and it goes to the link but when clicking on another link from that page it adds to the path and then it can't find the page. My routes work through the basic controllers that return a view only for now
For example
Example:
Home page=http://127.0.0.1:8000/
Click on Movies=http://127.0.0.1:8000/movie/index
Click on Movie Actor=http://127.0.0.1:8000/movie/actor/index
from movies to the next view it does not work as you can see the link path is wrong it should be http://127.0.0.1:8000/actor/index
please if anyone has any suggestion that might help.
Please edit your questions with the code and include the relevant code for the future. The code you posted doesn't contain any links (Edit: in your first few comments), which gives me a reason to believe you pasted the wrong thing.
The problem (without seeing any of your code) is likely here.
<a href="movie/index".....</a>
The way this (a) element works, which has nothing to do with Laravel, but is purely HTML, is that it will add movie/index to the current path you are linking from because you are giving it a "relative" URL.
If you add this link from, e.g. yoursite.com - it will link to yoursite.com/movie/index if you do it from yoursite.com/dashboard, it will link to yoursite.com/dashboard/movie/index.
Instead, you do not want a relative path, so you need to start with a / like this.
<a href="/movie/index".....</a>
You can read more about HTML tags here: https://www.w3schools.com/tags/att_a_href.asp.
Check named routes in documentation.
Route::get('/user/profile', function () {
//
})->name('profile');
You can get absolute url in blade template with route helper.
Text

Identical anchor ids on two pages: How to link from one page to the anchor on the other page

I have two websites page1 and page2. On every page there is a download form which I can access through the anchor id #DownloadForm.
On page1 I'd like to create a link to the download form on page2. I thought this would work:
But when clicking on this link (in Chrome) it takes me to the download form on page1. As if the anchor expression was evaluated first and then the rest of the href is ignored.
Btw: I'm using Wordpress but I guess that's not relevant here.
If anyone has a hint for me, I'd highly appreciate!
Have you tried the full page uri? I tried this and it worked for me in chrome and firefox.

The hash of id of an anchor link is to be replaced with a slash in URL

I am having a static website built in HTML5, and having the scrolling pages. The link to the pages is specified by the help of inline anchor tag, and with the help of an Id it scrolls to the particular div and the url changes. for eg mysite.com#section1 if I move to secion 1 div.
I want to replace this # to / in the url and the page should be scrolling as well.
Can anyone please help me in achieving this.
Thanks in advance :)
Its great that you are using HTML5.
The goodies which this great 5th version of HTML has bestowed upon us include the History API
With this API you can change the page URL (within the same domain) without redirecting/reloading.
The function is pushState.
-Relfor
you can use jquery or js
url = url.replace("#", "/");

Weird problem with simple HREF link

I'm putting a simple href link inside my html page:
http://search.mastertour.co.il/?mode=page&page=12077&lang=rus
the link can be found at the bottom of the page near the cleopatra head image.
Now, while the page is in a subdomain, the link referes to a TLD but the page cannot redirect to the link. It shows a "half-baked" page while trying to access the link directly (not through the html link) shows the page fine.
Any idea???
Get rid of the window.open(), this is all you need:
здесь
I'm guessing it has something to do with the onclick attribute you have attached. Do you really need it? Also, i'm guessing you're using it to force that link to open in a new tab/window - you really shouldn't, as the user should have that kind of control.