Answer the question
In order to leave comments, you need to log in
Angular.js: how to put markup in line at placeholder position?
The project uses a not-so-beautiful solution that we are going to fix. There is an array of objects coming from the server and describing which controls are needed to display and edit the model - these can be either simple controls in the form of input type="text", or more complex ones assembled from several tags, with validation by dynamically loaded lists, etc. . Currently, the markup of these controls is created manually (the file already contains > 4000 lines), but the managers had an idea to fix this crutch using angular.js. The problem is that the application supports localization, and the position of the same textbox is given as a placeholder in a string for a specific locale, for example (pseudocode):
var controlData = {
'typeOfControl': 'textAndTextbox',
'name':'underMiles',
'label':'Ignore travels under {0} miles',
'value':'123'
};
/*
тут следует код, который в соответствии с typeOfControl вызовет другой метод.
Тот в свою очередь знает какую разметку нужно собрать,
берет значение label и подставляет вместо {0} разметку textbox,
привязывает события и изменения value при изменения значения в textbox и добавляет валидацию.
*/
<div id="c_underMiles">
<span class='label'> Ignore travels under </span>
<input id="c_underMiles_textbox" type="text" value="123" />
<span class="label">miles</span>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question