
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
It is well known that syntax is going to change in the new major version of angular. But you could use a similar syntax in your current code, if you are coding in ES6 or are planning to migrate to ES6 in the future.
I have been migrating all my angular applications to ES6 and I have been using an evolutive approach for it the last months. In this series of posts i'm going to explain the different approaches used and why this was my final solution.
This approach is easy:
This allows me to do this:
// todoComponent/todoComponent.js
import template from './todoComponent.html';
class TodoController {};
export const name = 'todoComponent';
export default angular
.module('todo.component', [])
.directive(name, () => ({
controller: TodoController,
controllerAs: 'vm',
bindToController: true,
scope: {},
template
}))
.name
import todoComponentModule, {name as todoComponent} from '../todoComponent/todoComponent.js';
import template from 'todoItem.html';
class ItemController {};
export default angular
.module('todo.item', [todoComponentModule])
.directive('todoItem', () => ({
controller: ItemController,
controllerAs: 'vm',
bindToController: true,
scope: {},
require: [todoComponent],
template
}))
.name
I realized that I had been repeating the same code in almost all of my directives.
{
controller: TodoController,
controllerAs: 'vm',
bindToController: true,
scope: {},
template
}
Looking at the new syntax I thought, why not use ES7 Decorators to remove boilerplate code?, Now the previous example can be written like this:
// todoComponent/todoComponent.js
import { Component, View } from 'ng2-syntax';
import template from './todoComponent.html';
export const name = 'todoComponent';
@Component({
selector: name
})
@View({
template
})
class TodoController {};
export default angular
.module('todo.component', [])
.directive(name, TodoController.component).name
import todoComponentModule, {name as todoComponent} from '../todoComponent/todoComponent.js';
import template from 'todoItem.html';
export const name = 'todoItem';
@Component({
selector: name,
require: [todoComponent]
})
@View({
template
})
class ItemController {};
export default angular
.module('todo.item', [todoComponentModule])
.directive('todoItem', ItemController.component).name
Angular modules has a big caveat. If two modules with the same name are instanced, the last one is the one that is registered. This could mask your errors and make it really hard to debug. My solution for this was the creation of an Utils function to create a module with an unique name (The name is not needed, every time you need to use it import the module and use the default value). The original code with the new utils looks like this:
// todoComponent/todoComponent.js
import { Component, View, exportAsNgModule} from 'ng2-syntax';
import template from './todoComponent.html';
export const name = 'todoComponent';
@Component({
selector: name
})
@View({
template
})
class TodoController {};
export default exportAsNgModule(TodoController);
import { Component, View, exportAsNgModule} from 'ng2-syntax';
import todoComponentModule, {name as todoComponent} from '../todoComponent/todoComponent.js';
import template from 'todoItem.html';
export const name = 'todoItem';
@Component({
selector: name,
require: [todoComponent]
})
@View({
template
})
class ItemController {};
export default exportAsNgModule(ItemController, {
dependencies: [todoComponentModule]
});
TODO
FAQs
Simulate angular2 syntax in the angular1 projects
We found that ng2-syntax demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.