Template Parse Errors not matching HTML - angular-material

I have been using mdTooltip and was running into issues so I am in the process of using MatTooltip in my project. When I run my app tho, I keep getting the following error
core.js:1449 ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'mdTooltip' since it isn't a known property of 'input'. ("ass="form-control" (blur)="submitAnswer(item.$key, updatedata.value)"
[ERROR ->][mdTooltip]="item.desc"
mdTooltipPosition="right">
"): ng:///OwnershipCostModule/OwnershipAdminComponent.html#133:29
but when I go to where it tells me to I have the following
<div class="row">
<div class="col-12">
<div class="input-prepend input-group">
<span class="input-group-addon">$</span>
<input type="number" #updatedata [placeholder]="item.amount" [value]="item.amount" id="default" name="default" class="form-control" (blur)="submitAnswer(item.$key, updatedata.value)">
</div>
</div>
</div> -- line 133
I'm not sure why I'm getting the error as I replaced all instances of mdTooltip in my project.
Edit: This is what the submitAnswer function looks like
submitAnswer(key: string, answer: number) {
if (answer) {
this.answerdata.update(key, { amount: answer });
}
}
answerdata is a FirebaselistObservable

I realized that I was looking at the wrong component, and was able to get rid of the template parse error.

Related

Angular reactive formgroup clear error in component not clearing from template

I am dynamically clearing the errors of my reactive form like:
this.courseForm.setErrors(null);
But the errors are still displayed in my template:
<form [formGroup]="courseForm" autocomplete="off">
<div class="alert-group" *ngIf="submitted && formGroup.errors?.coursedates">
<div *ngFor="let err of formGroup.errors?.coursedates?.value" role="alert" class="error">
{{err}}
</div>
</div>
</form>
Is there a way to clear formgroup errors in template as well?
thanks
Errors for each control doesn't populate for formgroup errors. So clearing formgroup errors doesn't remove the errors from each of its form-controls.
We need to setErrors(null) for each control inside formgroup. Here is how we do it.
Object.keys(this.courseForm.controls).forEach(key => {
this.form.get(key).setErrors(null);
});
Make sure to mark it as answer if the solution fixes your issue.

about $_POST warning

I have a problem with $_POST. I am adding data to my mysql database with this code and it is working.;
if (isset($_POST["d_kayit"])){
$denetci=$dbpdo->prepare("INSERT INTO denetciler(name,pass) VALUES(:name, :pass)");
$denetci->bindParam(":name",$_POST["denad"],PDO::PARAM_STR);
$denetci->bindParam(":pass",$_POST["sif"],PDO::PARAM_STR);
$denetci->execute();
}
But in the same form i want to use $_POST["denad"] for another insert. It is giving me "Notice: Undefined index: denad in" error. Sample code that giving error is;
if (isset($_POST["add"]))
{
echo "Person: ".$_POST["denad"];
}
Can you help me please?
If this:
if (isset($_POST["add"]))
{
echo "Person: ".$_POST["denad"];
}
is yielding notice: Undefined index: denad then you probably don't have inputs "add" and "denad" on the same form. Or it is an unchecked checkbox.
Edit based on the code of your HTML form. You'll need something like this, you can't end your form with </form> like you did until you included all needed input fields:
<form action="" method="post">
<!-- content here -->
<input name="denad" id="denad" type="text" style="margin-top:2px; width:200px; height:30px;"></input>
<input type="submit" class="get_file" id="K_ekle" name="add" onclick="test()" value="Kişiye Ekle" style="float:left;"></input>
<!-- more content here -->
</form>

grails 3 gsp using domain object constraints failing

In grails 2 we were able to reference the domain object constraints in a gsp as to keep the html 5 configration dry. On grails 3 (tried both 3.1.10 and 3.2.0.RC1) I get an error for code I tested in grails 2 successfully. I am trying to reference the constraint matches in the attribute phone and use that for the HTML 5 pattern. The scaffolding use to generate this code but for Grails 3 the scaffolding generates use the fields plugin so I cannot see that code. Any ideas?
Here is the domain object code:
class Disruption {
static constraints = {
phone(matches:/^[0-9]{10}$/, nullable:true)
email(email:true, nullable:false)
}
String name
String phone
String email
Here is the gsp code:
<div class="form-group ${hasErrors(bean: disruption, field: 'phone', 'error')}">
<label for="phone" class="control-label col-sm-3">
Phone
</label>
<div class="col-sm-2">
<g:textField name="phone" style="width: 7em" class="form-control" title="Phone 10 digits" pattern="${disruption.constraints.phone.matches}" maxlength="10" placeholder="##########" value="${disruption.phone}"/>
</div>
</div>
Here is the exception:
URI
/disruption/create
Class
java.lang.NullPointerException
Message
Request processing failed; nested exception is org.grails.gsp.GroovyPagesException: Error processing GroovyPageView: [views/disruption/create.gsp:92] Error executing tag : Error evaluating expression [disruption.constraints.phone.matches] on line [58]: Cannot get property 'phone' on null object
Caused by
Cannot get property 'phone' on null object
Domain Objects need to use the constrainedProperties and Command Object need to use the constraintsMap see examples below.
<g:textField name="phone" style="width: 7em" class="form-control" title="Phone 10 digits" pattern="${disruption.constrainedProperties.phone.matches}" maxlength="10" placeholder="##########" value="${disruption?.phone}"/>
OR for Command Objects
<g:textField name="phone" style="width: 7em" class="form-control" title="Phone 10 digits" pattern="${searchCommand.constraintsMap.phone.matches}" maxlength="10" placeholder="##########" value="${searchCommand?.phone}"/>

Fine-grained error messages in Angular Dart forms

I have the following form with some simple validation rules:
<form name="signup_form" novalidate ng-submit="ctrl.signupForm()">
<div class="row">
<input placeholder="Username"
name="username"
ng-model="ctrl.username"
required
ng-minLength=3
ng-maxLength=8>
</div>
<div ng-show="signup_form['username'].dirty &&
signup_form['username'].invalid">
<!-- ... -->
</div>
<button type="submit">Submit</button>
</form>
I would like to display specific error messages for required, ng-minLength and ng-maxLength, but I'm not having success being able to drill down into signup_form['username'].errors to get the specific error.
I can access the errors map just fine in the controller, it is in the markup that I cannot get a handle on the specific error. I would like to be able to do roughly something like this:
<div ng-show="signup_form['username'].errors['minlength'].invalid>
<!-- ... -->
</div>
I.e., something like the following in angularJS:
<div ng-show="signup_form.username.$error.required">This field is required</div>
A working example for
Inspired by this filter I tried this approach again
Angular 0.9.9
#NgFilter(name: 'errors')
class ErrorFilter {
call(val) {
if(val != null) {
return val.map.keys;
}
return null;
}
}
and in the markup
{{signup_form['username'].errors | errors}}
EDIT for Angular 0.9.10
#NgFilter(name: 'errors')
class ErrorFilter {
call(val) {
if(val != null) {
return val.keys;
}
return null;
}
}
and in the markup
{{signup_form['username'].errorStates | errors}}
I learned from the discussions I have observed in the AngularDart Github repo that better solutions are on their way.
related open issue
When this https://github.com/angular/angular.dart/pull/771 is landed
hopefully better solutions are possible.

knockoutmvc - unable to parse bindings

I have an ASP.NET MVC site and I am trying to get knockout-mvc working with it.
I have created a View Model in the C# code called Refund that contains among other things a Voucher called Vouchertype and a List<Country> called Countries. Voucher has a variable of type int called VoucherNumber
This View Model is passed into a strongly defined view Refund\Index
I am trying to get knockout-mvc to bind the values in Refund.Voucher.VoucherNumber to a textbox, and the Values in Refund.Countries to a drop-down list. On the controller I have hardcoded the values of Voucher.Vouchernumber and added two countries to the Country list.
Here is my View Code:
#using Resources
#using PerpetuumSoft.Knockout
#model MVC.Models.RefundViewModel
#{
var ko = Html.CreateKnockoutContext();
}
<div id="refundformcontainer">
<div id="headersection">
<div id="pagetitlecontainer">#Language.RefundVouchers</div>
<div id="helpercontainer">
<label id="lblhelper">To begin enter a voucher number or scan a barcode</label>
</div>
</div>
<div id="vouchercontainer">
<div id="voucherdetailscontainer">
<h5>#Language.VoucherDetails</h5>
<div id="vouchernumbercontainer" class="initialvoucherfield">
#Html.LabelFor(x=>x.Voucher.VoucherNumber)
#ko.Html.TextBox(x=>x.Voucher.VoucherNumber)
</div>
<div id="countrycontainer" class="initialvoucherfield">
#Html.LabelFor(x=>x.Voucher.Country)
<select ko.Bind.Options(x=>x.Countries).OptionsText("Name").OptionsValue("CountryId").Value(x=>x.Voucher.CountryId) ></select>
</div>
</div>
</div>
</div>
#ko.Apply(Model);
When the page loads, neither controls are bound to.
When I look at the generated source the following code is generated
<script type="text/javascript">
var viewModelJs = {"Refund":null,"Voucher":{"VoucherId":0,"VoucherNumber":123456789,"Country":null,"CountryId":0,"Retailer":null,"RetailerId":0,"PurchaseDate":"0001-01-01T00:00:00","CustomsStampDate":null,"InvoiceNumber":"","LineItems":[],"TotalPurchasePrice":0.0},"Countries":[{"CountryId":380,"Name":"Italy"},{"CountryId":724,"Name":"Spain"}]};
var viewModel = ko.mapping.fromJS(viewModelJs);
ko.applyBindings(viewModel);
</script>
knockout-2.2.0.js and knockout.mapping-latest.js are both included in the page
The error I am getting is
0x800a139e - JavaScript runtine error: Unable to parse bindings
Message: [Object Error]
Bindings value: Voucher().VoucherNumber
I then changed the Refund View model so it had a property VoucherNumber and had the textbox reference this instead of the Voucher.VoucherNumber property
#ko.Html.TextBox(x=>x.VoucherNumber)
When I ran this I got the same unable to parse bindings error, but this time for the country
Bindings value: options : Countries, optonsText : Name, optionsValue : CountryId
Does anybody have any idea what is causing this?
i think, this should work.
<select #ko.Bind.Options(x=>x.Countries).OptionsText("'Name'").OptionsValue("'CountryId'").Value(x=>x.Voucher.CountryId) ></select>

Resources