+ Start a Discussion
Dominic SebastianDominic Sebastian 

dynamic drop down using the id and name in angular JS

Hi I would like to display dynamically the drop down of the id and name in angular JS. Please let me know how here is the code.
// In the controller SafetyAuditController
    global static string searchProject(string sSiteId){
       // id myId1 = UserInfor.getUserId();
       // system.debug(myId1);
        Site__c Site1 = [Select Id, Name , Project__c, Project__r.Name,Site_Master__r.Name, Site_Master__r.Id From Site__c where Site_Master__r.Id = :sSiteId LIMIT 4];
        return Site1.Project__r.Name; // here I am only displaying the name I must also                                                                     // display the id.
// In the angular Javascript 
// the app.service
 this.SearchProject = function(siteId){
            var deferred = $q.defer();

            Visualforce.remoting.Manager.invokeAction('SafetyAuditController.searchProject', siteId, function(retVal, e) {   
                $rootScope.$apply(function() {
            }, {escape:true} );

            return deferred.promise;
//the function  search Project

 var promiseProjects = SiteSvc.searchProject($scope.siteId);
        promiseProjects.then( function (retVal){
            $scope.searchProj =[ { name : retval} ]

// on the Visualforce page, which I should also display the id
  <div ng-controller = "Ctrl_SafetyAuditSection">
                    You have selected:{{searchProj}}
               <div dropdown-select = "searchProj"
the Site Master object is the lookup relationship with the site object hence I need to fetch the site master id to process the query.