Comments (6)
I've observed that this issue will not occur when starting in tree mode, then switching to code mode. It does occur when defaulting the mode to code.
Not sure if it makes a difference, but I am passing in my model as an object (not JSON string).
from ng-jsoneditor.
data must be passed as ng-model.
see this code: http://jsfiddle.net/angulartools/sd3at5ek/
from ng-jsoneditor.
Thanks for your response.
In the example that I provided to you in jsfiddle, data is passed as ng-model like in your example:
<div ng-jsoneditor="onLoad" ng-model="obj.data" options="obj.options" style="width: 400px; height: 300px;"></div>
Also, obj
was added to the $scope
as in your example:
$scope.obj = {data: json, options: {mode: 'code'}};
The only difference is that I would like that editor will start in "code" mode instead of "tree". If you simply change mode
in your example to code
, then editor will display an empty object.
from ng-jsoneditor.
I have the same problem. It is working when I open page first time and not for second and next times. First time I download json data from service so it takes some time. After refresh it gets data quickly (probably from cache) and it fails because when I set value of my model editor is not loaded.
I fixed problem by waiting with assigning value to model until editor is initialized.
I do something like this:
<div data-ng-jsoneditor="onEditorLoad" data-ng-model="definition" options="{ mode: 'code' }" class="editor"></div>
$scope.onEditorLoad = function (instance) {
$scope.editor = instance;
};
var setEditorData = function (data) {
if ($scope.editor) {
$scope.definition = data;
}
else {
$timeout(function() { setEditorData(data) }, 250);
}
}
I think this should be done inside component. So component itself should check if editor is loaded and if not wait before process with model value.
from ng-jsoneditor.
Hello,
Did you find a way to solve this problem ? I have the issue everytime I use the "code" mode. Tree view works fine but "code" always displays an empty object.
from ng-jsoneditor.
Using $interval to fixed 'code' mode
$interval(function() {
vm.obj.data = data
}, 200,1);
from ng-jsoneditor.
Related Issues (20)
- Not able to use angular-json-editor and ng-jsoneditor together
- Switch to jsoneditor 5 version HOT 3
- angular 2 version?
- Option "change" has been renamed to "onChange" HOT 3
- Search function not work correctly
- Icons disappeared HOT 1
- Cannot read property 'hasOwnProperty' of undefined HOT 2
- Request Issue for the new release HOT 2
- Cursor in the wrong place? HOT 1
- New release?
- Appears without styling HOT 1
- How to disable editor HOT 1
- Rename this to angular-js-tools
- Ace broken in code mode?
- User shouldn't be able Insert fields when onEditable option is false HOT 1
- move to use new jsoneditor version as there are new features and bugfixes there HOT 1
- Disable editing of keys HOT 1
- diff or synch between 2json files
- Abililty to Suppress Errors HOT 6
- editing a value in tree mode causes collapse HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ng-jsoneditor.