As far as I know, the tag button
does not have the attribute href
.
Another point, if you want to navigate to the route /register , you need to change your location
for '/register' , removing the HTML from the path. Remember that you are accessing a route, not a physical path to your HTML.
If you use the code below, you must access the route '/register' as configured in your module.
<a class="btn btn-success" href="#/cadastro')">Cadastra-se</a>
If you want to use a button accessing a method from your controller, you should do similar to the code below:
<button class="btn btn-success" ng-click="go(/cadastro)">Cadastra-se</button>
And in your controller:
$scope.go = function(path){
$location.path(path);
}
The object $Location should be included as a dependency on the above code. It aims to give you an interface to access the browser URL. Any modifications made to the URL will reflect on the object $location
, and vice versa.
Dude, I got it using the <a class="btn btn-Success" href="#/register')">Register</a>, but the other one, I tried to do what you said and it didn’t work. Which controller do you refer to? Cadasctrl?
– GustavoSevero
@Gustavosevero in the controller to which your button belongs. If your button is inside a div <div ng-controller"Cadasctrl">[...] then yes, in Cadasctrl
– Vinícius