com.asayama.gwt.angular.site.examples.client.UrlHashParameterExampleDocumentation.html Maven / Gradle / Ivy
Show all versions of UrlHashParameter Show documentation
GWT Angular provides a mechanism for controlling the hash parameters in
the URL. The "hash" refers to the part of URL that begins with '#', and
the parameters are expressed in the form of key value pair.
For example, if you see the URL right now, you should see the hash,
#/examples?page=urlHashParameter
The hash param page=urlHashParameter
instructs Angular to
show the current example page.
Enter one of the below page name values in the text input, and click
"Go." This action will update the page
hash param, so that
you will be taken to that page. If you enter a value that we do not
recognize, you will be taken to textInput
page.
List of valid page names:
- {{ page.name }}
View
The view code is fairly straight forward. An input box wired to a model
named pageName
. The model is passed to the controller via
onClickGo()
method when the "Go" button is clicked.
Controller
The controller demonstrates two things. One is how to read the hash
parameter, and the other is how to set the hash parameter.
See onControllerLoad()
method. This method is called when
the controller is activated. It uses the RouteParams
service to parse the parameter by key, "page".
When the user clicks the "Go" button, the onClickGo()
method is invoked. This method uses the Location
service
to set the "page" parameter value to the new value passed from the view.
Configuration
The following modules are required in the gwt.xml.
The following Maven dependencies are required in the pom.xml.
<dependency>
<groupId>com.asayama.gwt</groupId>
<artifactId>gwt-angular-ngRoute</artifactId>
<version>{{ PROJECT_VERSION }}</version>
</dependency>
You can also browse the full source code on Github.
{{ GITHUB_SOURCE_URL }}/gwt-angular-site/gwt-angular-examples/UrlHashParameter