angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.56k stars 3.01k forks source link

transitions not update $scope model #3586

Closed nhernandez2 closed 6 years ago

nhernandez2 commented 6 years ago

My version of UI-Router is: (1.0.8)

Bug Report

Current Behavior:

I'm identifying from where to get to my current view and I need to update a model when it comes from a specific one.

var cargarDatos = function(){
            nuevoVehiculo = angular.fromJson(SessionFactory.getDataByKey('nuevoVehiculo'));
            if (nuevoVehiculo) {
                angular.copy(nuevoVehiculo, $scope.data);
            }
  }
$transitions.onSuccess({ from: 'trabajos/nuevo_trabajo' }, (trans) => {
       cargarDatos();
 });

Expected Behavior:

I need you to update the model. When I print $ scope.data, the values are found correctly, however in the HTML code the values are not updated.

christopherthielen commented 6 years ago

You haven't provided enough information for a bug report. Please provide a way to reproduce this reported bug. The issue template links to a base plunker (including ui-router) that you can use: http://bit.ly/UIR-Plunk1

I don't know where the variable $scope in your pasted code comes from, but it's probably not the correct thing to do. Transition hooks do not (and never will) have access to "the current scope". Is this part of a larger view controller? Is the view a parent or child of trabajos/nuevo_trabajo? Please provide the details.

This is not likely to be a ui-router bug. Please provide sufficient details to form a response. Closing for now, but re-open if sufficient information is added.

Please try StackOverflow for questions on how to use angularjs and ui-router: https://bit.ly/UIR-SOF