{{client.fullName...">

Can I stop the silence of Angular with an error?

I have the following table layout:

<tr ng-repeat="client in clientsIndex"> <td>{{client.fullName}}</td> <td>{{item.contactPhone}}</td> </tr> 

When the view visualizes for this, I see only one column, but nothing is written to the console. Is there any way that I can tell angular this is a debugging session and I would like to see large flashy error messages if I make a copy and paste the error?

+6
source share
2 answers

Of course, at a time when the expression {{}} is evaluated regardless of what the non-empty value can output, at least?

According to Angular 1.1.5, support for triple operators in templates is supported. This way you can define something like this to get the default value if undefined:

 <tr ng-repeat="client in clientsIndex"> <td>{{client.fullName}}</td> <td>{{item.contactPhone ? item.contactPhone : 'Error: not defined'}}</td> </tr> 

General structure: {{(condition) ? (expression if true) : (expression if false)}} {{(condition) ? (expression if true) : (expression if false)}} .

0
source

For the purpose of debugging, you can select an element using the angular.element ("") selectors and see the scope of this element to check the variable that you are trying to access inside the element, is inside the area accessible to this element. Check out the example below. I used id selector, you can use child selector.

 <tr id="canbeReplacedWithChildSelectors" ng-repeat="client in clientsIndex"> <td>{{client.fullName}}</td> <td>{{item.contactPhone}}</td> </tr> 

angular.element ("# canbeReplacedWithChildSelectors"). scope () do this and check client.fullName available in the scope.in scope of your case angular.element ("# canbeReplacedWithChildSelectors") .scope (). the client will give you undefined.

0
source

Source: https://habr.com/ru/post/987339/


All Articles