小编use*_*894的帖子

如何将服务注入AngularJS中的app.config

wikiApp.config(['$routeProvider','authService', 
  function($routeProvider,authService) {
var admin = authService.getLoggedin();

$routeProvider
    .when('/hjem',{
        templateUrl: 'partials/homeContent.html',
    admin: false
    })
  .when('/articles/:article',{
    templateUrl: 'partials/articles.html',
    admin: false
  })
  .when('/newArticle',{
    templateUrl: 'partials/postArticle.html',
    controller: 'articleController',
    admin: true
  })
Run Code Online (Sandbox Code Playgroud)

authService.getLoggedin()返回false或true,具体取决于用户是否登录.如果他们不被允许,我想不允许他们到Url.

但我收到此错误:错误:[$ injector:modulerr]由于以下原因无法实例化模块wikiApp:[$ injector:unpr]未知提供者:authService

service config angularjs

10
推荐指数
3
解决办法
4万
查看次数

如何从formData获取内容?

我已经在formData中创建了一个文件,如下所示:

    var fd = new FormData();
    fd.append('file', file);    
Run Code Online (Sandbox Code Playgroud)

如何从formData中获取内容?像文件名和文件?这样的事情?:fd.filename(), fd.getData(). 或者fd.get('file')检索文件?

html javascript form-data

5
推荐指数
2
解决办法
2万
查看次数

当布尔值更改值时,AngularJS,ng-show不起作用

AngularJS中的HTML页面.当布尔值设置为true时,我的ng-show不会显示div.

这是我的HTML文件:

<div class="container">
<div ng-if="!query" ng-hide="editBoolean">
    <h3>{{article.id}} - {{article.title}}</h3>
    <h4 ng-bind-html="article.text"></h4>
    <button ng-click="edit(true)">Endre tekst</button>
</div>

<div ng-show="editBoolean">

    <style>
    .ta-editor { 
        min-height: 300px; 
        height: auto; 
        overflow: auto; 
        font-family: inherit; 
        font-size: 100%; 
    } 
    </style> 

    <input type="text" ng-model="article.title" value="{{article.title}}">

    <div text-angular="text-angular" ng-model="article.text"></div>
    <button ng-click="update(article.text, article.title)">Lagre</button>
    <button ng-click="edit(false)">Avbryt</button>

</div>

<div ng-if="query">
    <h3>{{query}}</h3>
</div>  
Run Code Online (Sandbox Code Playgroud)

这是我的controller.js文件:

 // Article controller
wikiControllers.controller('articleController', ['$scope', 'articleService',     '$routeParams', '$sanitize', 
  function($scope, articleService, $routeParams, $sanitize){
$scope.editBoolean = false;
$scope.edit = function(editValue){
  this.editBoolean = editValue;
  console.log(this.editBoolean);
};
  }]);
Run Code Online (Sandbox Code Playgroud)

当我有console.log我的booleanfil时,它显示为true(值已更改)

javascript angularjs ng-show

4
推荐指数
1
解决办法
7465
查看次数

使用NodeJS中的gridfs按元数据删除文件

我试图使用gridfs删除我的mongodb数据库中的文件.我想删除所有带有metadata.relation = id的文件.这是我在NodeJS中的方法:

function deleteFiles(){
    gfs.remove({'metadata.relation': req.body._id }, function(err){
      if (err) return false;
      return true;          
    })
}
Run Code Online (Sandbox Code Playgroud)

错误是:

C:\ Users\Gaute\Documents\GitHub\WikiHelpSystem \node_modules\mongoose \node_module s\mongodb\lib\mongodb\gridfs\gridstore.js:1138
if(names.constructor == Array){

     ^
Run Code Online (Sandbox Code Playgroud)

TypeError:无法在Function.GridStore.unlink中读取未定义的属性'constructor'(C:\ Users\Gaute\Documents\GitHub\WikiHelpSystem \node_modules\mongoose \node_modules\mongodb\lib\mongodb\gridfs\gridstore.js:1138: 11)

javascript mongodb node.js gridfs

3
推荐指数
1
解决办法
2747
查看次数

标签 统计

javascript ×3

angularjs ×2

config ×1

form-data ×1

gridfs ×1

html ×1

mongodb ×1

ng-show ×1

node.js ×1

service ×1