+ Start a Discussion
Dominic SebastianDominic Sebastian 

dynamically drop down using the id and name in angular JS

Hi I would like

1.THe issue now is that it convert the id of the page to the required SOQL syntax.
2.Find a link to each of the object created.

// 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 ProjectSearch(retVal){
            $scope.searchProj =[ { name : retval} ]

// on the Visualforce page, which I should also display the id

   <div ng-controller = "ProjectSearch">
        <select ng-model = "Projectname">
            <option ng-repeat="Search in searchProj" > {{Search.name}}</option>
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.
to display dynamically the drop down of the id and name in angular JS. Please let me know how here is the code.