JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › General Discussions › Router using path to an external HTML
- This topic has 4 replies, 3 voices, and was last updated 5 days, 4 hours ago by
admin.
-
AuthorPosts
-
May 23, 2023 at 6:28 am #104843
Dawud Tan
ParticipantI got error when try to use router with path to an external HTML:
const router = new Smart.Router('tampilanUtamanya', '${mvc.basePath}/coba'); router.cache = true; router.setRoutes([{ path: '/', template: 'tampilanBeranda', title: 'Rumahnya' }, { path: '/cip', template: '.${mvc.basePath}/tentang/templatTentang.htm', styleUrls: ['./tentang/coba.css'], scriptUrls: ['./tentang/coba.js'], title: 'Tentangnya' }, { path: '/hubungi', template: 'templatHubungi', title: 'Hubungilah' } ]); router.route('/');
May 23, 2023 at 12:45 pm #104844svetoslav_borislavov
ParticipantHi,
Can you please share what error are you receiving?
A steps for reproducing the error would also be useful.Best Regards,
Svetoslav BorislavovSmart UI Team
https://www.htmlelements.com/May 24, 2023 at 1:04 am #104848Dawud Tan
Participantthe error is my route is not functioning as expected when I specify a path to an external HTML file, but instead it is just showing 404 not found error, the route configuration that I have passed as parameter to the setRoutes method is correct as explained in the documentation:
template: string - either the id of a local HTMLTemplateElement or a path to an external HTML file. The HTML contents serves as a template for the view of the route.
$(() => { const router = new Smart.Router('tampilanUtamanya', '${mvc.basePath}/coba'); router.setRoutes([{ path: '/', template: 'tampilanBeranda', title: 'Rumahnya' }, { path: '/cip', template: './tentang/templatTentang.htm', title: 'Tentangnya' }, { path: '/hubungi', template: 'templatHubungi', title: 'Hubungilah' }, { path: '/lainu', template: 'laine', title: 'lain2' } ]); router.route('/'); });
When I specify just the id of a local HTMLTemplateElement, it could be functioning as expected.
-
This reply was modified 5 days, 16 hours ago by
Dawud Tan.
May 24, 2023 at 2:47 am #104850Dawud Tan
Participantthe smart.router.js that I used come from Smart HTML’s Github Repository https://github.com/HTMLElements/smart-webcomponents/releases/tag/v15.0.0
in the source directory: /source/smart.router.js-
This reply was modified 5 days, 14 hours ago by
Dawud Tan.
May 24, 2023 at 1:31 pm #104856admin
KeymasterHi,
Have you checked https://www.htmlelements.com/docs/router/ which shows how to configure the router?
-
This reply was modified 5 days, 16 hours ago by
-
AuthorPosts
- You must be logged in to reply to this topic.