I am developing a JHipster generated Angular + Spring + Java + HTML5 application
I have an issue that keeps coming up in several projects I worked around it previously, but I would love to be able to actually solve it
I have the following html template:
<div class="form-group row">
<label class="control-label col-md-2">ID</label>
<div class="col-md-4">
<input type="text" class="form-control" id="id" name="id"
ng-model="orgLabAMR.id" readonly/>
</div>
<label class="control-label col-md-2">organism</label>
<div class="col-md-4">
<input type="text" class="form-control"
placeholder="Search"
ng-model="orgLabAMR.organism"
uib-typeahead="organism as organism.organismName for organism in organisms | filter:$viewValue | limitTo:8"
typeahead-editable="false"/>
</div>
</div>
<div class="form-group row">
<label class="control-label col-md-2" for="field_conventionalBloodCultureMethods">Conventional Blood Culture
Methods</label>
<div class="col-md-4">
<select class="form-control" name="field_conventionalBloodCultureMethods" id="field_conventionalBloodCultureMethods" ng-model="orgLabAMR.conventionalBloodCultureMethods"
ng-options="convBloodCulture as convBloodCulture for convBloodCulture in convBloodCultures"/>
</div>
<label class="control-label col-md-2" for="field_automatisedBloodCultureMethods">Automatised Blood Culture
Methods</label>
<div class="col-md-4">
<select class="form-control" id="field_automatisedBloodCultureMethods" ng-model="orgLabAMR.automatisedBloodCultureMethods"
ng-options="autoBloodCultMethod as autoBloodCultMethod for autoBloodCultMethod in autoBloodCultMethods"/>
</div>
</div>
<div class="form-group row">
<label class="control-label col-md-2" for="field_methodsOfIdentification">Methods Of Identification</label>
<div class="col-md-4">
<select class="form-control" id="field_methodsOfIdentification" ng-model="orgLabAMR.methodsOfIdentification"
ng-options="idMethod as idMethod for idMethod in idMethods"/>
</div>
<label class="control-label col-md-2" for="field_identificationDetails">Identification Details</label>
<div class="col-md-4">
<input type="text" class="form-control" name="identificationDetails" id="field_identificationDetails"
ng-model="orgLabAMR.identificationDetails"
/>
</div>
</div>
<div class="form-group row">
<label class="control-label col-md-2" for="field_standardSusceptibilityTestingMethod">Standard Susceptibility
Testing Method</label>
<div class="col-md-4">
<select class="form-control" id="field_standardSusceptibilityTestingMethod" ng-model="orgLabAMR.standardSusceptibilityTestingMethod"
ng-options="standardSuscTestMethod as standardSuscTestMethod for standardSuscTestMethod in standardSuscTestMethods"/>
</div>
<label class="control-label col-md-2" for="field_molecularSusceptibilityTestingMethod">Molecular Susceptibility
Testing Method</label>
<div class="col-md-4">
<select class="form-control" id="field_molecularSusceptibilityTestingMethod" ng-model="orgLabAMR.molecularSusceptibilityTestingMethod"
ng-options="molecularSuscep as molecularSuscep for molecularSuscep in molecularSusceps"/>
</div>
</div>
<div class="form-group row">
<label class="control-label col-md-2" for="field_automatisedSusceptibilityTestingMethod">Automatised Susceptibility
Testing Method</label>
<div class="col-md-4">
<select class="form-control" id="field_automatisedSusceptibilityTestingMethod" ng-model="orgLabAMR.automatisedSusceptibilityTestingMethod"
ng-options="automaSusceTestMethod as automaSusceTestMethod for automaSusceTestMethod in automaSusceTestMethods"/>
</div>
<label class="control-label col-md-2" for="field_susceptibilityTestingMethodsDetails">Susceptibility Testing Methods
Details</label>
<div class="col-md-4">
<input type="text" class="form-control" name="susceptibilityTestingMethodsDetails"
id="field_susceptibilityTestingMethodsDetails"
ng-model="orgLabAMR.susceptibilityTestingMethodsDetails"
/>
</div>
</div>
<div class="form-group row">
<label class="control-label col-md-2" for="field_susceptibilityMethodsComments">Susceptibility Methods
Comments</label>
<div class="col-md-10">
<input type="text" class="form-control" name="susceptibilityMethodsComments"
id="field_susceptibilityMethodsComments"
ng-model="orgLabAMR.susceptibilityMethodsComments"
/>
</div>
</div>
<button class="btn btn-danger margin10" ng-click="removeOrganismLaboratoryAMR(study, orgLabAMR)">remove Organism
Laboratory {{orgLabAMR.id}}
</button>
When loading it in localhost it shows all elements fine, like this:
But when loading in production it doesn't parse all elements, it shows up like this:
Now the funny thing(s) are that I have several templates just like this one for other entities and they all load their elements just fine.
When in browser and looking up the elements it doesn't show them in the code snippets, although when checking in jenkins workspace the html file is exactly the same as in the local version.
After trying with prod profile local debug and checking all minified files generated by gulp and finding all html elements in them I decide to focus on the markups, the magic came from changing autoclosable <select /> tags to <select></select> tags
Now the view comes up perfectly, but I am still very confused as for why this would only happen when on production as the browser is exactly the same one.
Related
I'm getting set of data by calling a GET method in angularjs.
controller
$scope.edit = function (id) {
var edit_url = 'http://localhost/AwtCW2012002/api/restApiController/editQuestion.json?question_id=' + id;
$http.get(edit_url)
.success(function (data) {
console.log(data);
})
.error(function () {
})
};
Data from the GET method is like follows
How can I pass the data into respective fields in my view (into placeholders, as this view is used to edit existing data)
view
<div class="container" ng-controller="questionEditCtrl">
<form class="form-horizontal" role="form" name='quizAdd' ng-submit="submit(data)">
<div class="form-group">
<label class="control-label col-sm-2" for="question">Question:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="question" ng-model="data.question" placeholder="Enter Question">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="answer1">Answer 1:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="answer1" ng-model="data.ans1" id="answer1" placeholder="Enter Answer 1">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="answer2">Answer 2:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="answer2" ng-model="data.ans2" id="answer2" placeholder="Enter Answer 2">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="answer3">Answer 3:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="answer3" ng-model="data.ans3" id="answer4" placeholder="Enter Answer 3">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="answer4">Answer 4:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="answer4" id="answer4" ng-model="data.ans4" placeholder="Enter Answer 4">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="answer5">Answer 5:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="answer5" id="answer5" ng-model="data.ans5" placeholder="Enter Answer 5">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="sel1">Select Correct Answer:</label>
<div class="col-sm-10">
<select class="form-control" ng-model="data.correct_ans" id="sel1">
<option>{{data.ans1}}</option>
<option>{{data.ans2}}</option>
<option>{{data.ans3}}</option>
<option>{{data.ans4}}</option>
<option>{{data.ans5}}</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
</div>
You are getting the response in array. Use ng-repeat to render you fields. What you perform ng-repeat, you can add placeholder like,
placeholder="Write Answer {{$index}}"
Firstly, populate a $scope variable with the data from the api for it to be available for binding in the template:
$http.get(edit_url)
.success(function (data) {
$scope.data = data; //populate a scope variable
})
.error(function () {
});
Then, you can use one time expressions :: for your placeholders as follows:
placeholder="{{::data.ans1}}"
This will ensure only the default value of data.ans1 which was fetched from the api will be used as the placeholder. All subsequent changes to data.ans1 will change the value, but the placeholder will remain the same.
I have a form that is collecting a user's personal information. I've started to add control to the form using bootstrap grid. I am having issue when I reach certain breaking point. For example, 768 and 781px, one of the control will be out of place. Then, it will fall back into place at 782px and work fine. I have 3 separate css files, but they don't have anything at the moment. How do I handle it when the control as is the case between 768 and 781px?
html file
<div class="row">
<div class="form-group">
<label for="FirstName" class="col-xs-12 col-sm-2 col-md-2 label-control">First Name:</label>
<div class="col-xs-12 col-sm-4 col-md-4">
<input type="text" id="FirstName" name="FirstName" class="form-control"/>
</div>
<label for="middleName" class="col-xs-12 col-sm-2 col-md-2 label-control">Middle Name:</label>
<div class="col-xs-12 col-sm-4 col-md-4">
<input type="text" class="form-control" name="middleName" id="middleName" />
</div>
<label for="lastName" class="col-xs-12 col-sm-2 col-md-2 label-control">Last Name:</label>
<div class="col-xs-12 col-sm-4 col-md-4">
<input type="text" class="form-control" name="lastName" id="lastName" />
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"></div>
<div class="form-group">
<label for="FirstName" class="col-xs-12 col-sm-2 col-md-2 label-control">Sex:</label>
<div class="col-xs-12 col-sm-4 col-md-4">
<select id="Sex" name="Sex" class="form-control">
<option>Select Sex</option>
</select>
</div>
<label for="middleName" class="col-xs-12 col-sm-2 col-md-2 label-control">DOB:</label>
<div class="col-xs-12 col-sm-4 col-md-4">
<input type="text" class="form-control" name="DOB" id="DOB" />
</div>
<label for="lastName" class="col-xs-12 col-sm-2 col-md-2 label-control">Race:</label>
<div class="col-xs-12 col-sm-4 col-md-2">
<select id="Race" name="Race" class="form-control">
<option>Select Race</option>
</select>
</div>
</div>
</div>
#media only screen and (min-device-width:768px) and (max-device-width:1024px){
}
#media only screen and (min-device-width:1024px) {
}
When the screen is less than 768px
The screen is between 768 and 781 px; the lastName field is out of place
Screen is 782px or more
Right So your question was wired, Ive tided up your code abit (not fully otherwise you wont learn) The form is now responsive from big screens down to phones.
You will see that I have only used col-md-xx to achieve the look you want. If you want something changes just pop a comment and ill be glad to do it for you
<div class="container">
<div class="row">
<div class="form-group">
<label for="FirstName" class="col-md-2 label-control">First Name:</label>
<div class="col-md-4">
<input type="text" id="FirstName" name="FirstName" class="form-control"/>
</div>
<label for="middleName" class="col-md-2 label-control">Middle Name:</label>
<div class="col-md-4">
<input type="text" class="form-control" name="middleName" id="middleName" />
</div>
<label for="lastName" class="col-md-2 label-control">Last Name:</label>
<div class="col-md-4">
<input type="text" class="form-control" name="lastName" id="lastName" />
</div>
</div>
<div class="col-md-12"></div>
<div class="form-group">
<label for="middleName" class="col-md-2 label-control">DOB:</label>
<div class="col-md-4">
<input type="text" class="form-control" name="DOB" id="DOB" />
</div>
<label for="FirstName" class="col-md-2 label-control">Sex:</label>
<div class="col-md-4">
<select id="Sex" name="Sex" class="form-control">
<option>Select Sex</option>
</select>
</div>
<label for="lastName" class="col-xs-12 col-md-2 label-control">Race:</label>
<div class="col-xs-12 col-md-2">
<select id="Race" name="Race" class="form-control">
<option>Select Race</option>
</select>
</div>
</div>
</div>
</div>
I have a typical contact form where I concat the values into a preview div with AngularJS. This works fine if all the fields are filled out. I would like to move this into a controller so that I can conditionally add some static text such as only put a slash between phone and fax if both those fields are filled. I cannot find any sample code that goes beyond concatenating a couple values.
<div class="col-md-offset-1">
<div class="form-group">
<label class="control-label col-sm-2" for="companyFirm">Company/Firm</label>
<div class="col-sm-10">
<input type="text" ng-model="companyFirm" class="form-control" placeholder="Enter your company or firm name" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="contact">Contact</label>
<div class="col-sm-10">
<input type="text" ng-model="contact" class="form-control" placeholder="Enter the full name of the listing contact">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="address">Address</label>
<div class="col-sm-10">
<input type="text" ng-model="address" class="form-control" placeholder="Enter your street address">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="city">City</label>
<div class="col-sm-10">
<input type="text" ng-model="city" class="form-control" placeholder="Enter your city">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="state">State</label>
<div class="col-sm-4">
<input type="text" ng-model="state" class="form-control" placeholder="Enter your state">
</div>
<!-- </div>
<div class="form-group"> -->
<label class="control-label col-sm-2" for="phone">Phone</label>
<div class="col-sm-4">
<input type="phone" ng-model="phone" ng-change="getPhoneFax()" class="form-control" placeholder="Enter your phone number">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="zipcode">Zip Code</label>
<div class="col-sm-4">
<input type="text" ng-model="zipcode" class="form-control" placeholder="Enter your Zip Code">
</div>
<!-- </div>
<div class="form-group"> -->
<label class="control-label col-sm-2" for="fax">Fax</label>
<div class="col-sm-4">
<input type="phone" ng-model="fax" class="form-control" placeholder="Enter your fax number">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email</label>
<div class="col-sm-10">
<input type="text" ng-model="email" class="form-control" placeholder="Enter your email address">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="website">Website</label>
<div class="col-sm-10">
<input type="text" ng-model="website" class="form-control" placeholder="Enter your website address">
</div>
</div>
</div>
<h4>60-word Description</h4>
<div class="col-md-offset-1">
<div class="form-group">
<label class="control-label col-sm-2" for="description"></label>
<div class="col-sm-10">
<div>You have used <span class="wordCount">{{description|wordCounter}}</span> of your allowed 60 words.</div>
<textarea ng-model="description" class="form-control" rows="4" required></textarea>
<span class="help-block">Your 60 word, plain text only description begins after the listing header. You will receive a proof for approval prior to publication.</span>
</div>
</div>
<div class="col-md-offset-3 col-sm-6" style="background:#ddd; padding:15px; margin-top:50px;">
<strong>Live preview of listing</strong>
<div style="background:#fff; border:5px solid #eee; padding:15px; line-height:1em;">
<strong><span class="text-uppercase" style="font-size:1.3em;" ng-show="companyFirm">{{companyFirm}}<br /></span>
<span ng-show="contact">{{contact}}<br /></span></strong>
<span style="font-weight:500;">
<span ng-show="address">{{address}}<br /></span>
<span ng-show="city">{{city}}, </span><span ng-show="state" class="text-uppercase">{{state}}</span> <span ng-show="zipcode">{{zipcode}}</span><br />
<span ng-show="phone">{{phone}} / </span><span ng-show="fax">Fax: {{fax}}<br /></span>
<span ng-show="email">{{email}}<br /></span>
<span ng-show="website">{{website}}<br /></span>
</span>
<span style="color:#787878;">{{description}}</span>
</div>
</div>
<div class="clearfix"></div>
</div>
http://plnkr.co/edit/1oqneNRXuTXhiqE7vKWw?p=catalogue
If I understand question correctly, in controller You can use standard js concatenate:
$scope.phoneFax = function() {
//You can also save result in variable;
return ($scope.phone ? $scope.phone : '')
+ ($scope.phone && $scope.fax ? ' / ' : '')
+ ($scope.fax ? 'Fax: ' + $scope.fax : '');
};
Template:
<span>{{phoneFax()}}</span>
Also you can make it directly in the template:
<span ng-show="phone">{{phone}}</span>
<span ng-show="fax && phone"> / </span>
<span ng-show="fax">Fax: {{fax}}<br /></span>
i'm using camunda 7.2
In my process i have two user tasks (the first one a simple form to insert data, and the second one to show the same form readonly).
I'm using embedded forms.
I have the following form but i have a problem: using the ng-if directive i don't able to instantiate process variable, while if i use ng-show it works.
<form role="form" name="form" cam-form class="form-horizontal">
<div ng-if="typeRequest == 'firstCase'">
<h4 class="text-center">title</h4>
<!-- Oggetto -->
<div class="form-group">
<label for="oggetto" class="col-sm-4 control-label">Oggetto:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="oggetto" cam-variable-name="oggetto" cam-variable-type="String" required="required">
</div>
</div>
<!-- Nota descrittiva -->
<div class="form-group">
<label for="notadescrittiva" class="col-sm-4 control-label">Nota descrittiva:</label>
<div class="col-sm-8">
<textarea class="form-control" rows="3" id="notadescrittiva" cam-variable-name="notaDescrittiva" cam-variable-type="String"></textarea>
</div>
</div>
<!-- Data -->
<div class="form-group">
<label for="data" class="col-sm-4 control-label">Data:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="data" cam-variable-name="data" cam-variable-type="String" required="required">
</div>
</div>
<!-- Indirizzo -->
<div class="form-group">
<label for="indirizzorichiesta" class="col-sm-4 control-label">Indirizzo:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="indirizzorichiesta" cam-variable-name="indirizzo" cam-variable-type="String" required="required">
</div>
</div>
</div>
Please, any idea?
Thanks in advance
I think this is because ng-if does not renders anything in the DOM.
You probably should use ng-show instead.
I have form which contains some fields and have validated these fields by using angular.validator. The error messages are displayed under every fields. But I want to display this error messages using tooltip. For example , if some particular field is not valid , the error message should be shown on the right of the field box. I didn't found a solution from other posts of stackoverflow. How to do this ?
I want to show this field is required in a tooltip. ( by making directive) .
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Contact No</label>
<div class="col-sm-8">
<input type="text" ng-model="proFormSubmit.contactNo" validator="[required, number]" class="form-control" id="" placeholder="" validation-message="Only numeric values are valid!">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Profile Picture</label>
<div class="col-sm-8 companyLogo"> <img src="assets/img/user.png" alt="..." class="img-rounded col-sm-3 ">
<input type="file" id="exampleInputFile" ng-model="proFormSubmit.profilePic">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Language</label>
<div class="col-sm-8">
<select class="form-control" ng-model="proFormSubmit.language" validator="[required]">
<option></option>
<option value="english">English</option>
<option value="spanish">Spanish</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Address 1</label>
<div class="col-sm-8">
<input type="text" ng-model="proFormSubmit.address1" validator="[required]" class="form-control" id="" placeholder="">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Address 2</label>
<div class="col-sm-8">
<input type="text" ng-model="proFormSubmit.address2" validator="[required]" class="form-control" id="" placeholder="">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">City</label>
<div class="col-sm-8">
<input type="text" ng-model="proFormSubmit.city" validator="[required]" class="form-control" id="" placeholder="">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">State</label>
<div class="col-sm-8">
<select class="form-control" ng-model="proFormSubmit.state" validator="[required]">
<option></option>
<option value="Indonesia">Tamilnadu</option>
<option value="Indonesia">Kerala</option>
<option value="Indonesia">Rajasthan</option>
</select>
</div>
</div>
I use http://angular-ui.github.io/bootstrap which has a $tooltipProvider that allows you to modify behavior of the tooltip. Other than that this seems like a CSS + ng-show candidate