ui-sref

$stateParams converting value to string

末鹿安然 提交于 2019-12-08 22:03:18
问题 I am using UI-Router . Here's one of my state to which I am routing via ui-sref : .state("community", { url: "/community/:community_id", controller: "CommunityCtrl", templateUrl: "/static/templates/community.html" }) In one of my templates from where I go to 'community' state: <div ui-sref="community({community_id: community.community_id})"></div> Here's my community object: { name: 'Community name', community_id: 11 //int, not a string } As you can see the key 'community_id' contains an int

Insert html into div with angular keeping ui-router ui-sref property working

随声附和 提交于 2019-12-05 19:41:20
Here is my case: I have a div which needs to get some html injected from a function: <div ng-bind-html="myCtrl.getMyLink()"></div> in my controller I have: this.getMyLink = function () { return '<a ui-sref="app.go.to.state1">my link</a>'; } It works but not at all. All I have at the end in my html is only <a>my link</a> It's a link but the ui-sref redirection is not working. There is surely something I'm missing. How can I fix that? The content inside ng-bind-html doesn't get compiled by angular, it is intended for static html. You would need to use your own directive instead and either set a

angular ui.router ui-sref replace url characters - beautify

梦想的初衷 提交于 2019-11-30 05:14:07
I'm searching for a possibility to replace characters in the ui-sref, respecting the URL of a target. .state('base.product.detail', { url: 'detail/:productName-:productId/' The URLs now look like: Now: http://localhost/detail/My%20Product%20Name-123456789/ Should: http://localhost/detail/My-Product-Name-123456789/ I want to get rid of the %20 (which are also directly generated inside ui-sref="") and replace them with a minus (-). Any ideas how to do that? Regards, Markus Register a custom type that marshalls and unmarshalls the data. Docs here: http://angular-ui.github.io/ui-router/site/#/api