1

I'm new in AngularJs and I have a problem,I have two ui-view in the same page, and when push in the one button for example for show the view goals, appear the form goal in the ui-view 1 and also in the second ui-view at the same time,I worked with states.I don't know how to do for when push one button only show the form belonging to one ui-view,

look my source:

HTML

    <button class="btn btn-success"
    ng-click="go('projectShow.milestones.reports')">New Report</button>

    <div ui-view class="crearreport"></div>


    <button class="btn btn-success"
    ng-click="go('projectShow.milestones.goals')">New Goals</button>

    <div ui-view class="creargoal"></div>

Controllerjs:

    $scope.go = function(route){ $state.go(route);  };

RouteJs:

    .state('projectShow.milestones.goals', {
                    templateUrl: '../assets/projects/formulario.html', })           
    .state('projectShow.milestones.reports',{
                        templateUrl: '../assets/reports/formularioReport.html'  })

Regards! and thanks for your time !

1
  • can you share your HTML? it would be helpful to see how you are using the ui-view directives Commented Sep 11, 2014 at 23:23

1 Answer 1

5

Since you have multiple ui-view directives you need to give each one a name so you can target them individually.

According to the ui-router wiki

You can only have one unnamed view within any template (or root html)

<!-- Unnamed -->
<div ui-view></div> 

<!-- Named -->
<div ui-view="viewName"></div>

There are more details on how to setup ui-router & ui-view here. https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-view

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

1 Comment

Perfect @jcruz now it works! thanks for your time ! just had to assign name to ui-view, and add the name the view in the state. greetings !

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.