|
Yes, but why don't we have to watch in case of using "add()"? Does Angular watch for functions automatically and for using variables in view do we have to watch them manually?
|
|
|
|
|
Because you're binding to a function in the markup. That means that every time a digest cycle is run, that function is executed. That's definitely not the ideal way to bind, and potentially extremely buggy.
Have a look at the Scope Lifecycle section of:
AngularJS Developer's Guide[^]
The important thing to remember is that the page rendering (anything on the template) is processed when the $digest is run, so loading functions directly into it can become a very expensive process.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
OK. What's the ideal way to bind?
|
|
|
|
|
If you absolutely need an aggregate from other scope properties bound to a scope property, the ideal way to bind is to $scope.$watch the base properties.
If you need a transform from a scope property, but do not need the result bound to a property (a totals row, for instance) the ideal way is either native functions or filters.
Methods should really be saved for event handling and processing.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Hi,
I am trying to use AngularJS in my application, I am new to AngularJS, I am trying to use it with ASP.Net MVC 5, can anybody please help me? I am trying to execute the npm install from my Application route folder where project.json exists, but npm install is saying project.json file doesn't exist even it exists.
But I have just copied the project.json from some other Project, I don't know if its wrong or I shouldn't do it. But I don't know what to write in my project.json file. I don't have any other files copied too.
Should I have some other files? Any help is going to be very helpful, thanks in advance
My project.json file as below
{
"webroot": "wwwroot",
"version": "1.0.1-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Glimpse": "2.0.0-beta1",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx46": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Post your file structure and the actual error message here otherwise difficult to answer.
|
|
|
|
|
Hello,
I have created a job application form.
I need to send this form converted as .pdf file via mail.
Code behind
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.html;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Text;
using System.Net.Mime;
using System.IO;
namespace myproject
{
public partial class ApplicationForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Session.Remove("clicks");
}
}
protected MemoryStream getMemoryStream()
{
StringWriter sw = new StringWriter();
HtmlTextWriter w = new HtmlTextWriter(sw);
this.Page.RenderControl(w);
string s = sw.GetStringBuilder().ToString();
SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf();
SelectPdf.PdfDocument doc = converter.ConvertHtmlString(s);
MemoryStream Stream = new MemoryStream();
doc.Save(Stream);
doc.Close();
return Stream;
}
protected String getHtml()
{
StringWriter sw = new StringWriter();
HtmlTextWriter w = new HtmlTextWriter(sw);
this.Page.RenderControl(w);
string s = sw.GetStringBuilder().ToString();
return s;
}
protected void add_Click(object sender, EventArgs e)
{
int rowCount = 7;
rowCount = Convert.ToInt32(Session["clicks"]);
rowCount++;
Session["clicks"] = rowCount;
for (int i = 0; i < rowCount; i++)
{
TextBox TxtBoxE = new TextBox();
TextBox TxtBoxP = new TextBox();
TextBox TxtBoxD = new TextBox();
TextBox TxtBoxS = new TextBox();
TextBox TxtBoxR = new TextBox();
Label lblE = new Label();
Label lblP = new Label();
Label lblD = new Label();
Label lblS = new Label();
Label lblR = new Label();
TxtBoxE.ID = "TextBoxE" + i.ToString();
TxtBoxP.ID = "TextBoxP" + i.ToString();
TxtBoxD.ID = "TextBoxD" + i.ToString();
TxtBoxS.ID = "TextBoxS" + i.ToString();
TxtBoxR.ID = "TextBoxR" + i.ToString();
lblE.ID = "LabelE" + i.ToString();
lblP.ID = "LabelP" + i.ToString();
lblD.ID = "LabelD" + i.ToString();
lblS.ID = "LabelS" + i.ToString();
lblR.ID = "LabelR" + i.ToString();
lblE.ID = "LabelE" + i.ToString();
lblP.ID = "LabelP" + i.ToString();
lblD.ID = "LabelD" + i.ToString();
lblS.ID = "LabelS" + i.ToString();
lblR.ID = "LabelR" + i.ToString();
lblE.ID = "LabelE" + i.ToString();
lblP.ID = "LabelP" + i.ToString();
lblD.ID = "LabelD" + i.ToString();
lblS.ID = "LabelS" + i.ToString();
lblR.ID = "LabelR" + i.ToString();
lblE.ID = "LabelE" + i.ToString();
lblP.ID = "LabelP" + i.ToString();
lblD.ID = "LabelD" + i.ToString();
lblS.ID = "LabelS" + i.ToString();
lblR.ID = "LabelR" + i.ToString();
lblE.Text = "Employer " + (i + 1).ToString() + " : ";
lblP.Text = "Position " + (i + 1).ToString() + " : ";
lblD.Text = "From-Until : ";
lblS.Text = "Salary " + (i + 1).ToString() + " : ";
lblR.Text = "Reason for Leaving " + (i + 1).ToString() + " : ";
Panel1.Controls.Add(lblE);
Panel1.Controls.Add(TxtBoxE);
Panel1.Controls.Add(lblP);
Panel1.Controls.Add(TxtBoxP);
Panel1.Controls.Add(lblD);
Panel1.Controls.Add(TxtBoxD);
Panel1.Controls.Add(lblS);
Panel1.Controls.Add(TxtBoxS);
Panel1.Controls.Add(lblR);
Panel1.Controls.Add(TxtBoxR);
}
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
string fname = "applicationForm" + DateTime.Now.ToString("yyMMddHHmmss") + ".pdf";
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress(txtmymail.Text);
mailMsg.To.Add("my-email@gmail.com");
mailMsg.IsBodyHtml = true;
mailMsg.Subject = "Contact Details";
MemoryStream file = getMemoryStream();
FileStream filePDF = new FileStream(fname, FileMode.Create, FileAccess.Write);
file.WriteTo(filePDF);
file.Close();
filePDF.Close();
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Application.Pdf);
System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(fname, ct);
attach.ContentDisposition.FileName = fname;
ContentDisposition disposition = attach.ContentDisposition;
disposition.CreationDate = DateTime.Now;
mailMsg.Attachments.Add(attach);
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
mailMsg.Priority = MailPriority.Normal;
smtp.Credentials = new System.Net.NetworkCredential("my-email@gmail.com", "my-email-password");
smtp.Timeout = 250000;
smtp.EnableSsl = true;
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
};
smtp.Send(mailMsg);
Response.Write("<Script>alert('Thanks for contact us,our team will be contact you as soon as possible')</Script>");
txtfname.Text = "";
txtlname.Text = "";
txtfaname.Text = "";
txtmoname.Text = "";
txtmymail.Text = "";
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationForm.aspx.cs" EnableEventValidation="false" Inherits="icts.ApplicationForm" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server" >
<meta charset="UTF-8"/>
<title>Job Application</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"/>
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<link href="css/style.css" rel="stylesheet"/>
</head>
<body>
<form method="get" runat="server" id="form1">
<div class="container">
<h5>GENERAL INFORMATION</h5>
<div class="row">
<div class="col-md-6" id="col-md-6">
<div class="col-sm-9">
<div class="col-xs-8 col-sm-6">
<span>Surname</span>
</div>
<div class="col-xs-8 col-sm-6">
<asp:TextBox ID="txtlname" runat="server"></asp:TextBox>
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-sm-9">
<div class="col-xs-8 col-sm-6">
<span>Name</span>
</div>
<div class="col-xs-8 col-sm-6">
<asp:TextBox ID="txtfname" runat="server"></asp:TextBox>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6" id="col-md-6">
<div class="col-sm-9">
<div class="col-xs-8 col-sm-6">
<span>Date of Birth</span>
</div>
<div class="col-xs-8 col-sm-6">
<asp:Textbox type="date" runat="server" ID="bday"></asp:Textbox>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<asp:Panel ID= "Panel1" runat = "server"></asp:Panel>
<asp:Button ID="Button2" runat="server" Text="Add field" OnClick="add_Click" />
</div>
</div>
<div class="row">
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="btnsubmit_Click" />
</div>
With this code i am able to send a .pdf attachment via mail, but some of the fields are empty.
My form has text boxes, date input and radio buttons.
What would you suggest?
Thank you,
|
|
|
|
|
You might have better luck in the ASP.NET forum.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
How to add languages on a website?
How to security a website professionally?
|
|
|
|
|
Try Google for research questions.
|
|
|
|
|
Member 12847869 wrote: How to add languages on a website? What does this mean? Do you want multiple languages to show? Do you want the user to change the language? Are you translating everything?
Member 12847869 wrote: How to security a website professionally? Is there a database back-end? What kind of server? IIS? Apache? Do you need to secure certain pages or the whole site? Is anonymous allowed?
Hopefully you can see that your question needs a ton more detail for anyone to help.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have created an API with Client Identifier, Client Secrets, Auth URL and Access Token URL in Vimeo. Still searching for solution to fetch private videos from Vimeo using REST/ JSON/ JQuery.
Any help appreciated to provide some sample code to fetch private videos from Vimeo using REST/ JSON/ JQuery.
|
|
|
|
|
I would suggest starting at Vimeo Developer API[^].
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
How do I get apis for Facebook, Google talk, skype, whatsapp for my project using javascript and html? How can i import my facebook, google talk, skype and whatsapp friends and chat through my website?
|
|
|
|
|
Go to Facebook, Google etc developer websites and study the documentation.
|
|
|
|
|
Thanks Mr. Richard MacCutchan. I followed that process I am able to login to facebook and google but I got nothing to import friends into my website. For facebook i used a code which provide me only list of friends to tag them not for chat. In google i used gapi.client.people.list but it returns item[] zero means no friends. For Skype they have mentioned that APIs are not public and same for whatsapp, So I can't login to skype and whatsapp. If you have solution please guide.
|
|
|
|
|
Member 12336044 wrote: For Skype they have mentioned that APIs are not public and same for whatsapp, So I can't login to skype and whatsapp. If you have solution please guide. And exactly how do you think we can provide a solution to that?
|
|
|
|
|
Sir I m now in programming field so i thought there can be any solution that experts can give that is not directly mentioned on internet. So that why I asked.
|
|
|
|
|
If Skype etc say there is no public API then there is nothing you can do to get round it.
|
|
|
|
|
perhaps this is also very difficult to learn
|
|
|
|
|
is virtual world one of the most
|
|
|
|
|
<input id="rdo1" type="radio" name="rdoTest" value="Hello" />
<input id="rdo2" type="radio" name="rdoTest" value="World" />
<var id="test1" onchange="alert('2');">Test Value</var>
$(document).ready(function () {
$('[name=rdoTest]').change(function () {
$('#test1').text($('[name=rdoTest]:checked').val());
});
$('#test1').change(function () {
alert($('#test1').text());
});
});
My code here but nothing happened
|
|
|
|
|
|
The second event is triggered by the radio change, you can either place the alert in it or get it to trigger the second event, e.g.
<script>
$(document).ready(function () {
$('[name=rdoTest]').change(function () {
$('#test1').text($('[name=rdoTest]:checked').val());
$("#test1").trigger("change");
});
$('#test1').change(function () {
alert($('#test1').text());
});
});
</script>
Peter Leow
https://www.amazon.com/author/peterleow
|
|
|
|
|
Hello, I am modifying a web page with a lot of CSS code. There are many div tags. Mid-way on the page are div tags that enable a button to appear. I wish for this particular button to automatically click when the page loads. I have tried many combinations of JavaScript and JQuery but nothing so far works.
The button is defined by div tags comparable to this:
<div class="Btn-info">
<div class="Btn-btn active">
<strong>THE BUTTON</strong> <span></span>
</div>
...
</div>
I haven't yet figured out if the second div name is "Btn-btn active", or whether it is named "Btn-btn" and active is an attribute.
My efforts at coding either a JavaScript or JQuery way to automatically click the button I see on the page have not worked. I have tried these variations:
<script type="text/javascript">
jQuery(function () {
jQuery('.div.Btn-btn').click();
})
</script>
OR
<script type="text/javascript">
jQuery(function () {
jQuery('.Btn-btn').click();
});
</script>
OR
<script type="text/javascript">
jQuery(function () {
jQuery('.Btn-info.Btn-btn').click();
});
</script>
OR
<script type="text/javascript">
jQuery(function () {
jQuery('.Btn-btn active').click();
});
</script>
So far nothing works. Does anyone out there have an idea about how to make this work? Many thanks if you do.
|
|
|
|