so in my angularjs project i'm trying to change my url from
http:/localhost/(project name)/#/home?ref=(page name) to
http:/localhost/(project name)/home/(page name)
i have added url rewrite in iis.
also i have added html5mode true and base url,now when i try to run my project
all my resource files,app files points to
localhost/app/controllers/controllers.js instead of
localhost/(project name)/app/controllers/controllers.js..
now if i try to add my project name in base url it add project name twice like this,
localhost/(project name)/(project name)/app/controllers/controllers.js
Can some one please tell me where i'm wrong?or why is this not working?
Thank you.
Related
I've been struggling with this for a week now. I use Anguarjs and I set the html5mode(true) to get rid of the hash sign "#" that you needed in the url before.
Everything works fine amd my URL logic works with Query Parameters.
www.domain.com/thecurrentpage/?title=banana
And it changes and refresh the page when I click on something else and then it displays the right content.
I just want to be able to have a link like:
www.domain.com/thecurrentpage/banana
And come to the same page.
That actually will point you to the first one with query params.
I feels like I've tried everything in the .htaccess file with rewrite rules and everything with angular routing. I just don't get it.
you want to use the : syntax in your routing.
In your routing add a route like this:
/thecurrentpage/:title
Then you can use:
$routeParams.title
To get the value "banana"
This might help ... AngularJS: Read route param from within controller
In my application i am passing parameters for controller and read it using javascript as below.
localhost:8080/app/conroller#parameter=value
now problem is if i open my conroller in url and than append #parameter=value than only it works.
but i want to put whole link in anchor tag.
and when i click outside application than it automatically reroute localhost:8080/app/conroller and don't accept parameters.Although when opening that url if i apped #parameter=value* part than it works perfect.
i am using html5mode = true.
i search lots of document but didnt find right solution for this.
Not exactly sure if I get what you are asking but I think this is what you are getting at:
href="/app/conroller#parameter=value" target="_self"
Try adding the target self.
If that doesn't work you could try setting a base url <base href="/"></base>
You could try using ? for the query parameter instead of the #
I am finding trouble to display my AngularJs page from Play framework 2.2
The Angular js page is located in the same project directory which is
C:\webProj\test\app\www\index.html
Note this index.html is not the index.scala.html that we have in play views directory
I need to render this page from my Play project.
I have tried this
GET /masterid controller.Assets.at("/app/www/",index.html)
but it gives a compilation error.
Explanation of the error
There are some syntax errors in this route configuration:
GET /masterid controller.Assets.at("/app/www/",index.html)
It should be controllers instead of controller, the path is wrong, and the parameters are not specified correctly. It could be written as:
GET /masterid controllers.Assets.at(path="/app/www", file="index.html")
Note that as written, this route will map only to the index.html file, not to any other resources under /masterid.
Solution with a separate directory
To behave exactly as asked, with a separate directory and a custom URL, you would need to specity a second asset route in addition to the default one. This would also require changing all usages of #routes.Assets.at to specify two parameters (folder and file), and adding a configuration to build.sbt:
playAssetsDirectories <+= baseDirectory / "app/www"
Solution using the public directory and a custom URL
The path of least resistance is to create the custom index.html file in the project's public directory. To use a custom URL as asked in the question, you could change the default asset path to "masterid" by changing this line in the routes file:
GET /assets/*file controllers.Assets.at(path="/public", file)
to this:
GET /masterid/*file controllers.Assets.at(path="/public", file)
In this case the custom index.html file could be accessed as:
http://localhost:9000/masterid/index.html
Relative URLs to other resources under the /public folder would work as well.
Solution using the public directory and the default URL
If you don't require the /masterid URL under the root, you can save your index.html file under public/app and refer to it as:
#routes.Assets.at("app/index.html")
This will resolve to:
http://localhost:9000/assets/app/index.html
Documentation
For more extensive instructions see Working with public assets.
Make it faster, just place your file in i.e.: /public/angular-app/index.html, so you can use it via:
#routes.Assets.at("angular-app/index.html")
Next (assuming that you have standard routes) you can just use static paths to your public assets, i.e. if image is placed in folder public/img/logo.png you can access it with:
<img src="/assets/img/logo.png" alt=""/>
So just by replacing public/ to /assets/ (slash at beginning to make sure you don't need to use base tag in head of document).
Im using Angular.js and I have several routes:
http://localhost/tool/new
http://localhost/tool/report/#/59FD59D56F20DDFA722F5B31796CAE3396C
tool/new is the form where a user would create a new report using the tool. The program then runs in the background and the user can access the report by going to tool/report/#/their-id where their-id is a big SHA1 hash.
That hash is a route param, if that hash is invalid I need to redirect the user back to tool/new. The problem Im having is that the program file structure is:
tool/new/index.html // The create new report form
tool/report/index.html // The report area
I've been trying to use $location to redirect like this:
$location.path('/new');
But it just redirects to tool/report/#/new and that doesn't help.
Does anyone know how to tell Angular to move up one directory and redirect?
Based on the answer from Branimir, I get the URL and trim it at the current (report) directory. I do this because the tool name and domain can change depending on the server its located on. This worked for me.
var dialog = $dialogs.notify('We were unable to find your tool run.','<p>It is possible that the URL you have entered is incorrect or that your tool run has been deleted due to inactivity.</p><p>Please confirm your URL and try again; or create a new tool run.</p>');
dialog.result.then(function(btn){
var url = $location.absUrl();
var base = url.substring(0,url.indexOf('/report/'));
window.location = base + '/#/new';
},function(btn){});
Note Im using $dialogs from here https://github.com/m-e-conroy/angular-dialog-service/blob/master/dialogs.min.js to tell the user the id is bad.
If you want to reload page use:
$window.location.href = 'http://localhost/tool/new';
$location service doesn't reload a page, it changes a URL in the same AngularJS application.
I'm setting up breadcrumbs in cakephp following the cookbook (cookbook). I'm doing this in my admin section (admin routing is on) and in my layout I have the line
echo $this->Html->getCrumbs(' > ','Home');
I change home to Admin Home and it displays fine, however the url links back to the website root i.e. website.com/ instead of website.com/admin. I've been looking around and can't find anything on this. I tried leaving out the second parameter in the method call which should then make it display the first breadcrumb in the array however it only shows the current breadcrumb for each page, not the whole trail.
Any help much appreciated.
You can see that the getCrumbs is hardcoded to '/'. You'll have to override getCrumbs to linking to admin, or alternatively just add an
$this->Html->addCrumbs('Admin','/admin');
to your code
You could use this line of jQuery:
$('#breadcrumbs').children('a').first().attr('href','/admin')
If upgraded to CakePHP 2.1, there is now support for array as the second param.