0

If user is not registered, register. I want to show registration form using ui-sref and ui-view.

included scripts :

<script src="node_modules/angular/angular.js"></script>
<script src="node_modules/angular-ui-router/build/angular-ui-router.min.js"></script>
<script src="app/app.js"></script>
<script src="app/signup/signup-controller.js"></script>

In the app.js defined state

(function () {
  angular.module('TimeWaste', ['ui.router'])
  .config(function($stateProvider){
    $stateProvider
      .state('signUp', {
        url : "/signup",
        templateUrl : "app/signup/signup.html",
        controller : "SignUpController"
      })
  })
}());

Then i have this html code in my index.html

<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
      <div>
        <input type="text" ng-model="login.email">
        <input type="text" ng-model="login.password">
        <button>Login</button>
        <a ui-sref="signUp">Create</a>

      </div>
    </div>
  </nav>

  <div ui-view></div>

Link is disabled, a view not loads.... Some help ?

1
  • Is it inside another view? Commented Nov 25, 2015 at 4:15

1 Answer 1

1

try something like this,

.config(function($stateProvider){
  $stateProvider
    .state('signUp', {
      url : "/signup",
      views: {
        "container@": {
          templateUrl: "app/signup/signup.html",
          controller: "SignUpController"
        }
      },
  })
})

Then put name on your ui-view

<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <div>
      <input type="text" ng-model="login.email">
      <input type="text" ng-model="login.password">
      <button>Login</button>
      <a ui-sref="signUp">Create</a>
    </div>
  </div>
</nav>
<div ui-view="container"></div>

ui-sref doesn't know which ui-view it will load because your ui-view and ui-sref is not on the same parent node. check on multiple and named views here https://github.com/angular-ui/ui-router

Sign up to request clarification or add additional context in comments.

1 Comment

Hmmm, i can access file(view) using localhost:3000/app/signup/signup.html I think it is something wrong with a reference ??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.