How to update an AngularJS directive when a scope variable is updated via
ajax?
I have the following directive:
MyApp.directive('myFilter', ['$filter','$rootScope',
function($filter, $rootScope)
{
var dir = {};
dir.restrict = 'E';
dir.templateUrl = 'views/myFilter.html';
dir.replace = true;
dir.scope =
{
name: '@',
model: '=',
};
dir.link = function(scope,el,attrs)
{
//stuff here
}
return dir;
}]);
Here's how I invoke it:
<my-filter model="someField" name="abcd" />
When the directive is first initalized, the someField is empty. Later on,
it is retrieved via ajax, and its value is filled in.
Question is, how can I watch for the value of someField to be updated?
When I do this:
scope.$watch(scope.model, function()
{
console.log( "changed, new val: ", scope.model );
}
This is only called once, when initalizing the directive, and the value
then is empty. When the value is retrieved via ajax (from $http.get), this
watch function is not called again. However, in other parts of the page
where I'm displaying {{someField}}, that value DOES update when ajax
request is fetched. So I don't think the problem has to do with doing
$scope.apply() after ajax request.
Bohl
Thursday, 8 August 2013
PHP Syntax Check please
PHP Syntax Check please
Is this the right syntax i am sure it is but i still get mysql said i have
an error in my syntax. By the way i'm running PHP 5.4.10. I have tried
using mysql instead of mysqli but it still does not work. Any help is
greatly appreciated.
<?php
$result = mysql_query("SELECT count(*) FROM User_info");
$row = mysql_fetch_row($result);
$num = $row[0];
echo $num;
?>
It says that the error in syntax is on the second line after PHP tag.
Is this the right syntax i am sure it is but i still get mysql said i have
an error in my syntax. By the way i'm running PHP 5.4.10. I have tried
using mysql instead of mysqli but it still does not work. Any help is
greatly appreciated.
<?php
$result = mysql_query("SELECT count(*) FROM User_info");
$row = mysql_fetch_row($result);
$num = $row[0];
echo $num;
?>
It says that the error in syntax is on the second line after PHP tag.
C-Linux-How to send C parameter value to awk script?
C-Linux-How to send C parameter value to awk script?
I'm quite new to Linux and not familiar with C. Here I have one question
about both.
I'm writing a C program to run in Linux. And I have a file names f.txt in
the same folder. With some fields like this:
Jason 12 Male
I want to compare the $2 of the txt file of each line with the value of
parameter a. If the second field of the line is greater than a, then print
the first field $1.
I tried codes like this but not work. Can anybody help? Thanks!
void main()
{ int a;
scanf("%d",&a);
char* comm="awk '{if($2>"+a+") print $1}' f.txt";
system(comm);
}
I'm quite new to Linux and not familiar with C. Here I have one question
about both.
I'm writing a C program to run in Linux. And I have a file names f.txt in
the same folder. With some fields like this:
Jason 12 Male
I want to compare the $2 of the txt file of each line with the value of
parameter a. If the second field of the line is greater than a, then print
the first field $1.
I tried codes like this but not work. Can anybody help? Thanks!
void main()
{ int a;
scanf("%d",&a);
char* comm="awk '{if($2>"+a+") print $1}' f.txt";
system(comm);
}
Parsing Solr status response XML with JAXB
Parsing Solr status response XML with JAXB
Solr returns status information in the following XML form (this is a
shortened version):
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2</int>
</lst>
</response>
I'd like to pull this into my Java application. I created the following code:
@XmlRootElement(name="response")
@XmlAccessorType(XmlAccessType.FIELD)
public class Response {
@XmlElement(name="lst")
private ResponseHeader responseHeader;
public ResponseHeader getResponseHeader() {
return responseHeader;
}
public void setResponseHeader(ResponseHeader responseHeader) {
this.responseHeader = responseHeader;
}
public Response() {}
}
for the root element, and
@XmlAccessorType(XmlAccessType.FIELD)
public class ResponseHeader {
@XmlElement(name="int")
private IntegerElement status;
@XmlElement(name="int")
private IntegerElement QTime;
....
}
for the code inside. Finally, there's this for the int fields:
@XmlAccessorType(XmlAccessType.FIELD)
public class IntegerElement implements Serializable {
@XmlTransient
private static final long serialVersionUID = 1L;
@XmlAttribute
protected String name;
@XmlValue
private int value;
...
}
When I try to unmarshal the piece of xml above, only one of the int
elements is filled. The other doesn't get set (i.e. null). No errors
though. How should I go about annotating these classes better?
Solr returns status information in the following XML form (this is a
shortened version):
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2</int>
</lst>
</response>
I'd like to pull this into my Java application. I created the following code:
@XmlRootElement(name="response")
@XmlAccessorType(XmlAccessType.FIELD)
public class Response {
@XmlElement(name="lst")
private ResponseHeader responseHeader;
public ResponseHeader getResponseHeader() {
return responseHeader;
}
public void setResponseHeader(ResponseHeader responseHeader) {
this.responseHeader = responseHeader;
}
public Response() {}
}
for the root element, and
@XmlAccessorType(XmlAccessType.FIELD)
public class ResponseHeader {
@XmlElement(name="int")
private IntegerElement status;
@XmlElement(name="int")
private IntegerElement QTime;
....
}
for the code inside. Finally, there's this for the int fields:
@XmlAccessorType(XmlAccessType.FIELD)
public class IntegerElement implements Serializable {
@XmlTransient
private static final long serialVersionUID = 1L;
@XmlAttribute
protected String name;
@XmlValue
private int value;
...
}
When I try to unmarshal the piece of xml above, only one of the int
elements is filled. The other doesn't get set (i.e. null). No errors
though. How should I go about annotating these classes better?
What design do I follow to convert my classic ASP pages to a Java Enterprise Web Application?
What design do I follow to convert my classic ASP pages to a Java
Enterprise Web Application?
There are so many Java technologies that it is difficult for me to know
where to start. I understand JSP and Servlets. I know what http servers to
use. Real basic stuff. What I don't understand is what I do after that?
I don't want to create a bunch of jsp and servlets. That's not very
different than what I have.
I need to query various databases. Some are direct hits. Some have
webservices I need to consume. I will have to create a login system that
hits active directly.
Aren't I supposed to do more to make a "big java" enterprise application?
I am hoping this does not fall into the immediate downvote category of
"what technology do I use?" If it does can someone kindly tell me where I
can ask things like this. I haven't had much luck on
programmers.stackexchange.com.
Enterprise Web Application?
There are so many Java technologies that it is difficult for me to know
where to start. I understand JSP and Servlets. I know what http servers to
use. Real basic stuff. What I don't understand is what I do after that?
I don't want to create a bunch of jsp and servlets. That's not very
different than what I have.
I need to query various databases. Some are direct hits. Some have
webservices I need to consume. I will have to create a login system that
hits active directly.
Aren't I supposed to do more to make a "big java" enterprise application?
I am hoping this does not fall into the immediate downvote category of
"what technology do I use?" If it does can someone kindly tell me where I
can ask things like this. I haven't had much luck on
programmers.stackexchange.com.
Json.net and JsontIgnore in Serializing
Json.net and JsontIgnore in Serializing
i have an object which have an attribute of Serializable, this class
inherit from abstract class which inherit from other class which also
Serializable which inherit from an interface
i have used
string included = JsonConvert.SerializeObject(msg,
Formatting.Indented,
new JsonSerializerSettings {
/*ContractResolver = new
NotificationPropertyResolver()*/
TypeNameHandling = TypeNameHandling.All});
as msg is the interface I want to send this object in SignalR and i see
that it dont ignore any member, i have decorated the interface and the
classes
is there solution for that? i have tried also to use resolver with my own
attributes - but still same results
i have an object which have an attribute of Serializable, this class
inherit from abstract class which inherit from other class which also
Serializable which inherit from an interface
i have used
string included = JsonConvert.SerializeObject(msg,
Formatting.Indented,
new JsonSerializerSettings {
/*ContractResolver = new
NotificationPropertyResolver()*/
TypeNameHandling = TypeNameHandling.All});
as msg is the interface I want to send this object in SignalR and i see
that it dont ignore any member, i have decorated the interface and the
classes
is there solution for that? i have tried also to use resolver with my own
attributes - but still same results
Custom filter Gmail emails on receiving, mark as important if phrase is found, archive if not
Custom filter Gmail emails on receiving, mark as important if phrase is
found, archive if not
We subscribe to a request for information press service, were they send us
15 / 20 emails a day (each with 20 or so queries in them) which are all
request from reporters / journalists, asking for an opinion / quote for an
article they are working on.
99% of these queries are irrelevant to us, but we have to sift through
them to make sure.
We use gmail / google apps for business for our emails i was wandering is
there a way that i can set a custom filter to skim through the content in
these email, if the phrase/s we are looking for them are not found then
archive them but if the phrases are found then mark it as important.
ie. if phrases 'design, architecture, interior design, furniture' are in
the email mark it as important, if not archive email.
found, archive if not
We subscribe to a request for information press service, were they send us
15 / 20 emails a day (each with 20 or so queries in them) which are all
request from reporters / journalists, asking for an opinion / quote for an
article they are working on.
99% of these queries are irrelevant to us, but we have to sift through
them to make sure.
We use gmail / google apps for business for our emails i was wandering is
there a way that i can set a custom filter to skim through the content in
these email, if the phrase/s we are looking for them are not found then
archive them but if the phrases are found then mark it as important.
ie. if phrases 'design, architecture, interior design, furniture' are in
the email mark it as important, if not archive email.
Subscribe to:
Comments (Atom)