Angular JS JSON编辑器错误:[$ compile:nonassign]

时间:2016-01-21 21:13:57

标签: javascript jquery angularjs angularjs-directive

我正在尝试使用angular js editor(这是一个建立在jquery json editor之上的指令)

但我收到以下错误:Error: [$compile:nonassign] Expression 'undefined' used with directive 'jsonEditorInput' is non-assignable!

请按以下方式查找我的代码:



var app=angular.module("myApp",["angular-json-editor"]);
  	app.controller("myController",function($scope){

      $scope.people={            
                "name": "Mr A. Payne",
                "age": 35,
                "company name": "ARAMARK Ltd." ,
                "address": {
                  "street": "30 Commercial Road",
                  "city area/district" : "Fratton",
                  "city/town/village" : "PORTSMOUTH",
                  "county": "Hampshire",
                  "postal code": "PO1 1AA"
                }            
      };
      

  		
      $scope.onError=function(err){
        alert(err);
      };

  		$scope.options={
  			"mode": "code",
        "modes": ['tree','form', 'code', 'text'],  			
        "history": false
  		};
		$scope.download=function(){
			ga('send', {
			  'hitType': 'event',          // Required.
			  'eventCategory': 'button',   // Required.
			  'eventAction': 'download',      // Required.
			  'eventLabel': 'nav buttons',
			  'eventValue': 1
			});
		};
  	});

<!DOCTYPE html>
<html lang="en">

<html ng-app="myApp">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Node All Admin | </title>

    <link href="lib/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
    <script src="lib/jsoneditor/dist/jsoneditor.css"></script>
    <link href="lib/angular-json-editor/angular-json-editor.css" rel="stylesheet" type="text/css">

</head>

<body ng-controller="myController" class="nav-md">
    <json-editor-input model="people"/>


    <br/><br/><br/> 
    <json-editor-input model="people" on-error="onError(err)"/>

    <br/><br/><br/> 
    <div json-editor model="people" options="options" style="height: 400px;"/>
</body>
  

<script src="lib/jquery/dist/jquery.js"></script>
<script src="lib/jsoneditor/dist/jsoneditor.js"></script>
<script src="lib/angular/angular.js"></script>
<script src="lib/angular-json-editor/angular-json-editor.js"></script>
<script src="app.js"></script>

</body>
</html>
&#13;
&#13;
&#13;

0 个答案:

没有答案