How to create an abstract route with global controller for your children in AngularJS

1

I am creating an application where I will create something similar to a wizzard of windows forms and for this I am using a routing as follows:

.state("vendaOrcamento", {
  url: "/vendaOrcamento",
  abstract:true,
  templateUrl: "templates/comercial/vendaOrcamento.html"
})
.state('vendaOrcamento.cliente', {
  url: "/cliente",
  views: {
    'tab-cliente': {
      templateUrl: "templates/comercial/vendaOrcamento/1cliente.html"
    }
  }
})
.state('vendaOrcamento.produtos', {
  url: "/produtos",
    views: {
      'tab-produtos': {
        templateUrl: "templates/comercial/vendaOrcamento/2produtos.html"
      }
    }
  })

I need both for the child client and for the child products to have a vendaOrcamento global object, so regardless of which child I am, I will always be working with the same object without losing the previously treated data, I basically need this:

$scope.vendaOrcamento = {
  cliente : {},
  produtos : {}
}

My problem is that I did not understand very well how I can work like this, I even tried to create a Controller directly in the parent view (saleOrcamento) but it did not work very well ... someone can give me a light please?

    
asked by anonymous 11.09.2015 / 17:05

2 answers

0

I gave a good deal of what @GuilhermeSantos said and it was a very functional option, but I ended up opting for a value because even if the person starts editing but leaves this screen I have back to the same continue where you left off

    
13.09.2015 / 12:48
3

You can try to use a factory to share data between controllers.

There is a lot of content ready, just search for something like " share data between controllers .

    
11.09.2015 / 21:44