简体   繁体   中英

How to select the GET data from a controller and use it as a POST value to another controller

I am using a backend server that a foreign key variable. I want to pass the value on a POST call via select options. So I take the controller and get all the values that I need. Problem is that angular says that the values are null. How can I make it see the values?

This is the HTML code:

<div class="form-group">
   <label for="cod_fac">Codul Facultatii</label>
     <div ng-controller="FacultateaCtrl">
       <select class="form-control" name="cod_fac" ng-model="cod_fac">
        <option  ng-controller="FacultateaCtrl" ng-repeat="facultate in facultati" value="{{ facultate.id }}">
          {{ facultate.denumirea }}
        </option>
      </select>
    </div>

Keep in mind that I am calling a controller in another controller.

Declare a service like so :

angular
      .module('yourModule', [])
      .service('yourService', yourService);

 // if you need any deps in this service
 yourService.$inject = [];

 function yourService(){
   var this = service;
   service.sharedData = [];
 }

Then you can access it by injecting 'yourService' into your controller, and you'll be able to access everything that is on the service object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM