当前位置:   jquery > 正文

如何限制用户在ui-ace编辑器中只编写一个javascript函数(方法)

javascript,angularjs,angularjs-directive,angularjs-scope,angularjs-ng-repeat,DevBox,在线流程图,编程,编程问答,程序员,开发者工具,开发工具,json解析,二维码生成,unix时间戳,在线开发工具,前端开发工具,开发人员工具,站长工具

这是我的控制器代码

  $scope.aceOptions = {
      workerPath: 'http://localhost:50871/Scripts/app/vendor/',     
      useWrapMode: true,
      showGutter: true,
      theme: 'chrome',
      firstLineNumber: 1,
      onLoad: function (_editor) {
          $scope.script = {};
          $scope.script.scriptCode = "function fieldName_columnName_" + "functionName(){\n\n\n}";             
          var _session = _editor.getSession();
          _session.setMode('ace/mode/javascript');
          var _renderer = _editor.renderer;

          _session.on('changeAnnotation', function () {
              $scope.annotations = [];
              $scope.annotations = _editor.getSession().getAnnotations();
          }),
          _editor.$blockScrolling = Infinity;

          _session.on("change", function (e) {               
              var currentValue = _editor.getSession().getValue();
              $scope.script.scriptCode = currentValue;
          });


      },
      require: ['ace/ext/language_tools'],
      advanced: {
          enableSnippets: true,
          enableBasicAutocompletion: true,
          enableLiveAutocompletion: true
      }
  }

我为ui-ace写了指令这是我的html代码

 

和指令代码是

SCSApp
.directive('javascriptEditor', [
    function () {          
        return {
            restrict: 'E',
            scope: {
                data: '=code',
                aceOption: '='
            },
            templateUrl: '/Scripts/app/shared/directives/javascripEditor/partials/javascriptEditor.html',
            link: function (scope, element, attrs) {
            }
        }
    }]);

这是我的javascriptEditor.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/jquery/detail/13527
推荐阅读
相关标签