Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

The ng g component plainsight/some-name makes a new directory when we use it.

The final output will be:
***
plainsight/some-name/some-name.component.ts
***
To avoid that, make use of the flat option ng g component plainsight/some-name --flat and it will generate the files without making a new folder
***
plainsight/some-name.component.ts
***
4 years ago
First install Bootstrap from npm:
***
npm install bootstrap@next
***
Then add the needed script files to to apps[0].scripts in angular-cli.json file:
***
"scripts": [
"../node_modules/bootstrap/dist/js/bootstrap.js"
],
***
Finally add the Bootstrap CSS to the apps[0].styles array:
***
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.css"
],
***
Restart ng serve if you're running it, and Bootstrap 4 should be working on your app.

This is best solution. But if you don't restart ng serve it never works. It is strongly recommended to do this last action.
4 years ago
destroy or something similar may come to the CLI, but it is not a primary focus at this time. So you will need to do this manually.

Delete the component directory (assuming you didn't use --flat) and then remove it from the NgModule in which it is declared.

If you are unsure of what to do, I suggest you have a "clean" app meaning no current git changes. Then generate a component and see what is changed in the repo so you can backtrack from there what you will need to do to delete a component.
4 years ago
***

{{a}}

***
When used with async pipe:
***

{{a.prop1}}
{{a.prop2}}

***
4 years ago
Encode
***
public static string Base64Encode(string plainText) {
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
***
Decode
***
public static string Base64Decode(string base64EncodedData) {
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
***
4 years ago
.NET 4.0 has a built-in library to do this:
***
using System.Web.Script.Serialization;
JavaScriptSerializer jss = new JavaScriptSerializer();
var d = jss.Deserialize(str);
***
4 years ago
async Main is now part of C# 7.2 and can be enabled in the projects advanced build settings.

For C# < 7.2, the correct way is:
***
static void Main(string[] args)
{
MainAsync().GetAwaiter().GetResult();
}


static async Task MainAsync()
{
/*await stuff here*/
}
***
4 years ago
The curly braces inside backgroundImage property are wrong.

Probably you are using webpack along with image files loader, so Background should be already a String: backgroundImage: "url(" + Background + ")"

You can also use ES6 string templates as below to achieve the same effect:
***
backgroundImage: `url(${Background})`
***
4 years ago
You can avoid the need for .bind(this) with an ES6 arrow function.
***
VK.api('users.get',{fields: 'photo_50'},(data) => {
if(data.response){
this.setState({ //the error happens here
FirstName: data.response[0].first_name
});
console.info(this.state.FirstName);
}

});
***
4 years ago
You can post axios data by using FormData() like:
***
var bodyFormData = new FormData();
***
And then add the fields to the form you want to send:
***
bodyFormData.append('userName', 'Fred');
***
If you are uploading images, you may want to use .append
***
bodyFormData.append('image', imageFile);
***
And then you can use axios post method (You can amend it accordingly)
***
axios({
method: "post",
url: "myurl",
data: bodyFormData,
headers: { "Content-Type": "multipart/form-data" },
})
.then(function (response) {
//handle success
console.log(response);
})
.catch(function (response) {
//handle error
console.log(response);
});
***
4 years ago
Parent:
***



***
Child:
***
handleLangChange = () => {
var lang = this.dropdown.value;
this.props.onSelectLanguage(lang);
}
***
4 years ago
***
const scrollTo = (ref) => {
if (ref /* + other conditions */) {
ref.scrollIntoView({ behavior: 'smooth', block: 'start' })
}
}

Item

***
4 years ago