Tuesday, 9 May 2017

Angular and Node confusing variables

My stack is: Angular 1.6.4 and Node v6.10.0. I use Node for the main routing of my site and Angular for the sub pages. I have multiple Angular apps for the same site due to some Angular limitations (out of scope for this issue).

My problem is - whenever I pass variables from an Angular controller, the site thinks it's coming from Node as they both have the same way to detect dynamic variables.

Code below:

var mainApp = angular.module('mainApp', []);

mainApp.controller('testController', ['$scope', function($scope){

$scope.profileID = '12345678';
console.log('$scope.profileID is: ' + $scope.profileID);//This prints out just fine

}]);

HTML:

<!DOCTYPE html>
<html lang="en" ng-app="mainApp">
<head>
  <script src="/jsLib/angular.min.js"></script>
  <script src="/angular/angularApp.js"></script>
</head>

<body ng-controller="testController">
  <div>
    <p></p><!--This comes out as blank-->
  </div>
</body>
</html>

I know I can use: $interpolateProvider.startSymbol('[{'); and $interpolateProvider.endSymbol('}]'); to change the symbols but then, it breaks some 3rd party tools I am using which aren't written to support this.

Does anyone know of another way? Also, I never pass anything from Node to the frontend. It is there purely for the routing and API purposes so if I can stop this "passing" of variables from Node, that will do the trick.

Thanks



via Shayan Khan

No comments:

Post a Comment