Convert {{}} to ng-bind for angular html pages
This plugin requires Grunt.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install bracestobind --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('bracestobind');
In your project's Gruntfile, add a section named bracestobind
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
bracestobind: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
grunt.initConfig({
bracestobind: {
options: {},
files: {
'dest/': 'src/**/*.html',
},
},
})
grunt.initConfig({
bracestobind: {
options: {
custom_tag: '<any-tag>' //by default it will take as <span> and add for label elements and tags which has text in braces
},
files: {
'dest/': 'src/**/*.html',
},
},
})
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
- v0.1.4 - Support ng-bind for labels and tags which have next element as
text
ideally if you put ng-bind on parent then internal element are completely ignored by angular. - v0.1.3 - Changes for current version
- Fix for multiple html/template page
- Support for directive/component {{}} text
- v0.1.1 - Currently supported for div and span elements.
-
Why I am in this earth want this stupid plugin?
Because it's hard to read
ng-bind
text/value for a us(developer).<div class="foo" value-pass-to-component="model" again-some-value-pass="{{text}}" one-more-value="example.test">{{bar}}</div>
VS
<div class="foo" ng-bind="bar" value-pass-to-component="model" again-some-value-pass="{{text}}" one-more-value="example.test"></div>
Which one is better for readable perspective?
//For me first one
-
Why I need a conversion {{}} is good?
In terms of performance it's slow compare to ng-bind.Below are the links:-
-
Look Great I want to use now but for all tags you guys are supporting? Yes we support for all tags except
label
one becauseng-bind
breaks for labels other way is to add some tag inside label and putng-bind
, but I feel its kind of hack apply so currently thinking of some other solution.If you guys has some solution then you can guys fork it and send me the solution it will be great help.
Any more question comes in your mind just add those question in Issue Forum.I will be happy to solve your problem.
Copyright (c) 2016 . Licensed under the MIT license.