AngularJS HTML formatting incorrect
See original GitHub issueI’m testing out the new HTML formatting on a AngularJS project at work. But unfortunately it messes up the code. I’m running the latest version of the VSCode plugin.
I’ll attach a GIF and the problematic markup for testing: Imgur
Code:
<div class="row">
<div class="col-xs-4 col-md-2">
<b>{{'statisticsSendReportName'|i18n}} {{"statisticsLatest" | i18n}} {{timeUnit}}</b>
<p>{{dataStatisticsMap.get(timeUnit).reportsCount}}</p>
</div>
<div class="col-xs-4 col-md-2" ng-show="overviewSelected">
<b>{{'statisticsSendReportName'|i18n}} {{"statisticsLatest" | i18n}} {{timeUnitSecondary}}</b>
<p>{{dataStatisticsMap.get(timeUnitSecondary).reportsCount}}</p>
</div>
<div class="col-xs-4 col-md-2">
<b>{{"statisticsTimeFor" | i18n}} {{"statisticsLatest" | i18n}} {{"statisticsSendReportName" | i18n}}</b>
<p>{{dataStatisticsMap.get(timeUnit).latestReportTime}}</p>
</div>
<div class="col-xs-4 col-md-2">
<b>{{'statisticsEventName'|i18n}} {{"statisticsLatest" | i18n}} {{timeUnit}}</b>
<p>{{dataStatisticsMap.get(timeUnit).eventsCount}}</p>
</div>
<div class="col-xs-4 col-md-2" ng-show="overviewSelected">
<b>{{'statisticsEventName'|i18n}} {{"statisticsLatest" | i18n}} {{timeUnitSecondary}}</b>
<p>{{dataStatisticsMap.get(timeUnitSecondary).eventsCount}}</p>
</div>
<div class="col-xs-4 col-md-2">
<b>{{'statisticsPollName'|i18n}} {{"statisticsLatest" | i18n}} {{timeUnit}}</b>
<p>{{dataStatisticsMap.get(timeUnit).pollsCount}}</p>
</div>
<div class="col-xs-4 col-md-2" ng-show="overviewSelected">
<b>{{'statisticsPollName'|i18n}} {{"statisticsLatest" | i18n}} {{timeUnitSecondary}}</b>
<p>{{dataStatisticsMap.get(timeUnitSecondary).pollsCount}}</p>
</div>
<div class="col-xs-4 col-md-2">
<b>{{'statisticsPollStatusName' | i18n}} <span class="glyphicon glyphicon-info-sign" uib-tooltip="{{'statisticsPollStatusTooltip' | i18n }}" tooltip-placement="right"></span></b>
<p>{{dataStatisticsMap.get(timeUnit).pollIntervalStatusOk ? 'yes' : 'no' | i18n }}</p>
</div>
<div class="col-xs-4 col-md-2">
<b>{{'statisticsValidationErrorName'|i18n}} {{"statisticsLatest" | i18n}} {{timeUnit}}</b>
<p>{{dataStatisticsMap.get(timeUnit).validationErrorsCount}}</p>
</div>
<div class="col-xs-4 col-md-2" ng-show="overviewSelected">
<b>{{'statisticsValidationErrorName'|i18n}} {{"statisticsLatest" | i18n}} {{timeUnitSecondary}}</b>
<p>{{dataStatisticsMap.get(timeUnitSecondary).validationErrorsCount}}</p>
</div>
</div>
When running the code on prettier.io > Try it out, I’m getting:
SyntaxError: Unexpected token (3:40)
1 | <div class="row">
2 | <div class="col-xs-4 col-md-2">
> 3 | <b>{{'statisticsSendReportName'|i18n}} {{"statisticsLatest" | i18n}} {{timeUnit}}</b>
| ^
4 | <p>{{dataStatisticsMap.get(timeUnit).reportsCount}}</p>
5 | </div>
6 | <div class="col-xs-4 col-md-2" ng-show="overviewSelected">
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
javascript - Incorrect Format Validation in AngularJS - Stack Overflow
I just check validation from controller and show modal if it is wrong. <!DOCTYPE html> <html> <link rel="stylesheet" ...
Read more >$http - AngularJS: API
Overview. The $http service is a core AngularJS service that facilitates communication with the remote HTTP servers via the browser's XMLHttpRequest object ...
Read more >Template type checking - Angular
In the most basic type-checking mode, with the fullTemplateTypeCheck flag set to false , Angular validates only top-level expressions in a template.
Read more >Angular currency Filter - W3Schools
AngularJS currency Filter ... The currency filter formats a number to a currency format. By default, the locale currency format is used.
Read more >Angular directives for Bootstrap - AngularUI
html ) - Add the ability to override the template used on the component (inner uib-datepicker). is-open $ (Default: false ) - Whether...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
By stressing
AngularJS
versusAngular
, I mean they are different framework, though they have similar name andAngular
evolves fromAngularJS
. As it is shown on #5466, they have a slight different grammar.@ikatyang On the fix in #5402, you did a great job! I have reviewed the code change and do find some rare cases and it should be addressed in #5480.
I don’t know anything about the implementation details, and the 1000 issues that you probably have to face to support every edge case.
But as a user, I would rather prefer that
print-width
is disregarded if there are uncertanties about how to handle whitespace (rather than breaking up the HTML-elements in multiple lines). In my opinion print-width is not as important for readability in HTML as in JS.For example, that this:
Would become: