Write scope within dynamic string - angularjs

I am working on localization within my angular project. It reads a JSON file which is having key and it's localized value in string.
Like: text1:"Localized text"
This prints "Localized text" on page correctly. But when I need to add some dynamic text in the string, like:
text1: "Showing page {{cur_page_num}} of {{total_pages}} pages"
where the cur_page_num and total_pages values will come from controller. I have tried
"Showing page {{cur_page_num}} of {{total_pages}} pages"
but it's printing {{cur_page_num}} and {{total_pages}} as it is without evaluating it.

use ng-bind-html
EX:
<p ng-bind-html="obj.text1"></p>
At this point you may get an error.
attempting to use an unsafe value in a safe context error
you need to either use ngSanitize or $sce to resolve that.

try storing the json values in an array .
iterate it on html & render it there .

if it is from template then your code should be like this,
text1: "Showing page " + {{cur_page_num}} + " of " + {{total_pages}} + " pages"
or if it is from controller then it can be like below,
text1: "Showing page " + $scope.cur_page_num + " of " + $scope.total_pages + " pages"

Related

SSIS Custom Column Property

I have a general question I'm hoping someone can answer about creating custom properties for use in a Data Flow Component.
Is it possible to create custom properties for use at the column level? I can create custom properties at the component level, no problem, but that does me no good.
I want to add two properties (Encrypt and Decrypt) to the Input Column metadata.
Say I have a collection of Input columns col1, col2, col3. As a developer, I would like to set col3's Encrypt value to true so, at run time, col3 gets encrypted before being loaded into a database.
I have successfully encrypted and decrypted using a custom component. Still, I used the values "e" and "d" in the column Description and then evaluated that Description during PreExecute. I set a state object based on the value of Description and add it to a collection that is processed during ProcessInput. I don't think using the Description is a good thing to do, and that is the need for the custom properties.
Do SSIS columns have custom properties?
The answer is yes. SSIS columns are objects that inherit the IDTSColumn130 interface. As mentioned in the SSIS documentation, this interface contains a property called CustomPropertyCollection that contains the collection of IDTSCustomProperty100 objects added to the input by the component.
Some components add some custom property to the SSIS columns such as the Derived Column Transformation. As I know, a custom component called FriendlyExpression is used to store the expression in plain text form. But, there is no way to add custom properties in the Integration Services package designer (Visual Studio).
How to add Custom Properties?
I think the only way is to create packages programmatically and edit those values or develop a custom SSIS component that adds these properties at runtime.
This is an example of reading the custom properties of a Derived Column transformation using C#. (Reference)
foreach (IDTSInputColumn localIColumn in localInput.InputColumnCollection)
{
if (localIColumn.CustomPropertyCollection.Count == 2)
{
repository.AddAttribute(componentRepositoryID, localInput.Name + " [" + localIColumn.Name + "] [ID: " + localIColumn.ID.ToString() + "]", "From [" + localIColumn.UpstreamComponentName + "] " + FormatColumnDescription(localIColumn.Name, localIColumn.DataType, localIColumn.Length, localIColumn.Precision, localIColumn.Scale) + " Expression " +
localIColumn.CustomPropertyCollection["FriendlyExpression"].Value != null ? localIColumn.CustomPropertyCollection["FriendlyExpression"].Value.ToString() : "Not Available"
);
}
else
{
repository.AddAttribute(componentRepositoryID, localInput.Name + " [" + localIColumn.Name + "] [ID: " + localIColumn.ID.ToString() + "]", "From [" + localIColumn.UpstreamComponentName + "] " + FormatColumnDescription(localIColumn.Name, localIColumn.DataType, localIColumn.Length, localIColumn.Precision, localIColumn.Scale) + " Expression (See Ouput Column)");
}
//repository.AddObject(localIColumn.Name, "", ColumnEnumerator.ObjectTypes.Column, componentRepositoryID);
}
Alternatives
You can store the columns metadata within an external data source (SQL, XML, ...) and load it at runtime. Or you can use the Description property as you mentioned in your question.

Output contents of label array in Blogger expression

I'm attempting to generate the labels of a blog post within the post container as classes, like so:
<div expr:class='"post hentry grid-item" + (data:post.labels any (l => l.name !="" : " " + l.name)' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'>
Help would be greatly appreciated!
As Lambda expressions in Blogger generate arrays(in some cases boolean and numbers as well) as their results, we need some way to iterate over that array. We can use a b:loop tag for that. Also, as we can't include a b:loop tag in class attribute (otherwise the Blogger's XML parser will show errors) therefore escaping the HTML and including the b:loop tag is one of the way. The code will look like -
<div class='post hentry grid-item <b:loop var="labelName" values="data:post.labels" ><b:eval expr='data:labelName.name + " " ' /></b:loop>' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'>
</div>

How to upload multiple files to the page

I am trying to upload multiple files to the page with
<input id="dropInput" type="file" multiple>
For one file it is as simple as:
driver.FindElement(By.Id("dropInput")).SendKeys(#"path-to-file");
As a user I can click Choose Files button and select number of files (with Ctrl) so in Open dialog I can see sth like: "file-1" "file-2"
From the script it does not work. I have tried different combinations of SendKeys argument:
#"file-1" + " " + #"file-2"
#"file-1" + ", " + #"file-2"
"\"path\\to\\file-1\" \"path\\to\\file-2\""
Path.GetFullPath(file-1) + " " + Path.GetFullPath(file-2)
"\"" + Path.GetFullPath(file-1) + "\" \"" + Path.GetFullPath(file-2) + "\""
The input accepts the last file only. The same with sending keys several times. For the last example I have got an exception:
unknown error: path is not absolute: "file-1" "file-2"
I am out of ideas.
I'd like to know if there is any simple solution for that before I'll start injecting jQuery scripts to the page under test.
Please advise.
Cheers,
Przemek

Filtering dataset with condition

I am using asp.net 2.0 and c#.
I have a dataset, which is getting the employee info. Now I want to filter the gridview based on a name that the user has put in the search textbox.
I am doing this:
DataSet ds = new DataSet("EmployeeInformation");
//........ loading DataSet ds with emploee info
string strExpr;
strExpr = "Name LIKE %" + txtSearchEmployee.Text.Trim() + "%";
ds.Tables[0].Select(strExpr);
I am getting an error in the last step, that the operator is missing.
Please guide me how can I achieve this. Thanks in advance.
You just need to add single quotes around your LIKE criteria:
strExpr = "Name LIKE '%" + txtSearchEmployee.Text.Trim() + "%'";
ds.Tables[0].Select(strExpr);

String Encoding Issue

I am having a very weird issue in the way strings get stored in my database, and as a result, I am getting these "unterminated string literal" errors in Javascript.
Here's an overview of what I am doing:
Platform: C#/ASP.NET MVC 1.0, SQL Server 2005, SparkViewEngine, YUI 2
In my view, I serialize an object into a JSON data structure using Json.NET from NewtonSoft.
<script type="text/javascript">
// <![CDATA[
var data = YAHOO.lang.JSON.parse("${Newtonsoft.Json.JsonConvert.Serialize(Model)}");
....
</script>
Normally, this works, but I noticed that one of the fields I pull from the database contains the following data, which causes the string to not be formed properly.
The database field is an NVARCHAR(2000).
For some of the entries, I get these weird characters in the string when I copy and paste from the database to notepad.
Compile ?Analysis ?& ?Recommendations? deck
In Firebug, it shows as a bunch of line breaks:
Analysis & Recommendations deck","StartDate":"1/19/10","FinishDate":"1/26/10","Duration":6.0,"
Compile 
Analysis 
& 
Recommendations
 deck
UPDATE
After talking to the user, I discovered that they were using the copying and pasting from a word document onto the HTML form.
The form itself uses the YUI Connection Manager to make an asynchronous POST call (AJAX) to save the form values.
The database saved the form field value along with any encoding associated with it.
It seems like there are characters in Word that are printable, but not in ASCII. Is there any way to detect this and encode correctly?
This appears to be a case of you not handling the quote characters properly. You have several ways to go. The way I use for comments for our web site is to make sure all quotes are encoded, both single and double, so that both your SQL, ASPX & Javascript won't hiccup.
Our method is for customer comment fields so we're overboard on the conversions.
Function SafeComment(ByVal strInput)
' Renders Any Comment Codes Harmless And Leaves Them HTML readable In An eMail Or Web Page
' Try: SafeComment("`~!##$%^&*()_+=-{}][|\'"";:<>?/.,")
SafeComment = ""
If Len(strInput) = 0 Then Exit Function
SafeComment = Replace(Replace(Replace( _
Replace(Replace(Replace( _
Replace(Replace(Replace( _
Replace(Replace(Replace( _
Server.HtmlEncode(Trim(strInput)), _
"-", "-"), ":", ":"), "|", "|"), _
"`", "`"), "(", "("), ")", ")"), _
"%", "%"), "^", "^"), """", """), _
"/", "/"), "*", "*"), "'", "'")
End Function
It's not pretty, but it does the job.

Resources