Update AngularJS HTML Template After Running Google Closure Compiler in Application Code

My application is assigned to the variable $ scope variable in the controller, for example, $scope.myVariable = 123;this code After starting the Closure Compiler turns into $scope.a = 123;and $scope.b = 123;and so on ...

My html templates have things like <p>{{ myVariable }}</p>I need to update the templates to <p>{{ a }}</p>to match the new name of the renamed property myVariable.

I know that I can use the CC annotation /** @expose */, or I can do something like $scope['myVariable'] = 123so that CC does not rename this particular property. However, I would like to keep the renaming of the properties of variables.

I have 2 options that I see:

  • Write a script that uses _props_map.out from CC and write a script that performs a search replaces strings in my HTML.

  • Write my templates in javascript so that CC also processes my templates and then runs a template function that spits out the html of the template.

What would be the best way to keep my variables renamed and update my html template?

+4
source share
1 answer

I believe the best way is not to rename the variables. I'm not sure what exactly you are trying to achieve, but, generally speaking, changing variables in templates does not make sense.

<p>{{ a }}</p> ; {{ a }} - , a .

- $scope.variables, ,

{ a: 123, b: 123 }

<p>{{ variables.a }}</p>.

- ?

0

All Articles