+ Start a Discussion
Abhilash Mishra 13Abhilash Mishra 13 

Remoting with angular js

Hi I am using angular js and remoteaction to modify the data on the page My code is
<---------visualforce page------>
<apex:page controller="testangular">
	<apex:includescript value="//ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"/>
	<apex:stylesheet value="{!URLFOR($Resource.EshopResource,'EShopResource/EshopProduct.css')}"/>
	<apex:stylesheet value="{!URLFOR($Resource.EshopResource,'EShopResource/fonts.css')}"/>
	<style>
		.v-align{
			vertical-align: middle !important;
			}
	</style>

	<div ng-app="myApp" ng-controller="customersCtrl"> 
				
						{{names}}
						<button ng-click="letsset()">Try me</button>
					</div>
				
	

	<script>
		function myfunc(){
			
		}
		var a;
		var app = angular.module('myApp', []);
		app.controller('customersCtrl', function($scope,$window) {
                      $scope.names='Firstname';
		     $scope.letsset=function(){
			testangular.actfast($scope.names,function(result,event){
				 		if (event.status){
				 			
				 			$scope.names=result;
				 			
				 			}
						});
		
			}
		
		});

	</script>
</apex:page>



<!---controller--->

public with sharing class testangular {
     @remoteaction
	 public static string  actfast(string s){
	  return s=='Firstname'?'LastName':'Firstname';
	 
 	

}
code works fine but the view changes abnormaly. some times lastname appear as soon as try me is clicked some time i need to double click

Please help
 
Best Answer chosen by Abhilash Mishra 13
ProlayProlay
Can you try in the Angular Controller
$scope.$apply();

All Answers

ProlayProlay
Try this 
return s.equals('Firstname')?'LastName':'Firstname';

 
Abhilash Mishra 13Abhilash Mishra 13
hi prolay 
Controller works fine.  its the the value of expression {{names}} that does not reflet change even after($scpoe.names =result)
ProlayProlay
Can you try in the Angular Controller
$scope.$apply();
This was selected as the best answer
Abhilash Mishra 13Abhilash Mishra 13
Hey Prolay 
Thanks :)
That Worked..................