使用angular ui router

时间:2015-09-10 14:10:17

标签: javascript angularjs angular-ui-router angular-ui-bootstrap

到目前为止我尝试了什么

app.js

var myapp = angular.module('myapp',['ui.router']);

    itaasContentApp.config(function($stateProvider, $urlRouterProvider) {

        $urlRouterProvider.otherwise('/404');

        $stateProvider.state('parent', {
            url:'/parent',
            templateUrl :'partials/parent.html',
            controller:'parentCtrl'
        })
          .state('parent.child',{
            url:'/child',
            templateUrl :'partials/child.html',
            controller  :'childCtrl'
        });

parentCtrl

    app.controller('parentCtrl', function($scope,$state) {

    var init=function()
    {
    //it will initialize the controller 
    }

init();
    //I am calling child state
    $state.go("parent.child");

    });

childCtrl

        app.controller('childCtrl', function($scope,$state) {

            init=function()
            {
            //it will initialize the controller <html data-ng-init='init()'>

            }
    //calling init

    init();

$scope.goBack=function()//I will call this method from  view
{
$state.go('^');
}

            });

问题

  • 从子状态导航到父状态init()的父进程是 不打电话可以请你帮忙吗

0 个答案:

没有答案