Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未添加AngularJS类ng作用域_Javascript_Angularjs_Angularjs Scope - Fatal编程技术网

Javascript 未添加AngularJS类ng作用域

Javascript 未添加AngularJS类ng作用域,javascript,angularjs,angularjs-scope,Javascript,Angularjs,Angularjs Scope,我遵循Angular教程,我在他们的示例中看到,ng scope通过一个指令添加到每个元素中 但是我自己的代码没有为每个指令添加ng作用域,从呈现数据开始,似乎每件事情都能正常工作,但出于某种原因,没有添加这个CSS类 我的应用程序是从一个Yeoman.io初学者项目开始的,所以我不确定该项目中是否有什么东西导致了这个问题 我在我的dropbox中添加了www.zip代码: 教程示例 我的例子 HTML App.JS // Ionic Starter App // angular.m

我遵循Angular教程,我在他们的示例中看到,ng scope通过一个指令添加到每个元素中

但是我自己的代码没有为每个指令添加ng作用域,从呈现数据开始,似乎每件事情都能正常工作,但出于某种原因,没有添加这个CSS类

我的应用程序是从一个Yeoman.io初学者项目开始的,所以我不确定该项目中是否有什么东西导致了这个问题

我在我的dropbox中添加了www.zip代码:

教程示例

我的例子

HTML

App.JS

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers', 'invoice1', 'invoice2', 'invoice3', 'test', 'myService'])

.run(function ($ionicPlatform) {
    $ionicPlatform.ready(function () {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        }
        if (window.StatusBar) {
            // org.apache.cordova.statusbar required
            StatusBar.styleDefault();
        }
    });
})

.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider

    .state('app', {
        url: "/app",
        abstract: true,
        templateUrl: "templates/menu.html",
        controller: 'AppCtrl'
    })

    .state('app.search', {
        url: "/search",
        views: {
            'menuContent': {
                templateUrl: "templates/search.html"
            }
        }
    })

    .state('app.browse', {
        url: "/browse",
        views: {
            'menuContent': {
                templateUrl: "templates/browse.html"
            }
        }
    })
    .state('app.playlists', {
        url: "/playlists",
        views: {
            'menuContent': {
                templateUrl: "templates/playlists.html",
                controller: 'PlaylistsCtrl'
            }
        }
    })

    .state('app.scopeHeirachy', {
        url: "/scopeHeirachy",
        views: {
            'menuContent': {
                templateUrl: "templates/sample/scopeHeirachy.html"
            }
        }
    })



    ;
    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/app/playlists');
});


检查javascript中是否添加了以下代码行。这通常会删除调试信息,即Ng范围。添加这些代码通常是为了提高生产代码的性能

$compileprovider.debuginfoenabled(false)

ionic-angular.js已重写addClass函数

下面是片段

jqLite.prototype.addClass = function(cssClasses) {
  var x, y, cssClass, el, splitClasses, existingClasses;
  if (cssClasses && cssClasses != 'ng-scope' && cssClasses != 'ng-isolate-scope') {
    //............

由于if条件
ng scope
ng隔离scope
即使启用了调试信息,也不会添加类。

您可以发布指令的代码吗?用一些代码重新发布(您需要更多还是足够?)@戴维西:我们能看看你的完整html吗?或者你的代码中有一个plunkr吗?angular版本与教程和你的代码是一样的?当然,最好的方法是什么?压缩www文件夹?我的意思是代码分布在多个文件中,我不确定要调试什么?我已经浏览了我的项目,但没有看到那一行,是不是我可以找到此属性的位置?它位于“app.config”中。如下所示。app.config(['$compileProvider',function($compileProvider){//disable debug info$compileProvider.debugInfoEnabled(false);}]);尝试为debugInfoEnabled设置true。查看ng作用域是否返回。app.config(['$compileProvider',function($compileProvider){//disable debug info$compileProvider.debugInfoEnabled(true);}]);我尝试了这段代码,能够关闭和打开ng绑定,但ng作用域没有出现..config(函数($stateProvider,$urlRouterProvider,$compileProvider){$compileProvider.debugInfoEnabled(false);$stateProvider})注意:我尝试了true和false.config(函数($stateProvider,$urlRouterProvider,$compileProvider){$compileProvider.debugInfoEnabled(true);$stateProvider})在控制台中尝试此操作。让我们检查作用域元素是否可用。angular.element($0)。scope()投票给你。我也这么认为。希望这对David有好处。:)我觉得这可能是个问题,但我在这里做了一些调试,找不到一个例子,这个函数甚至接收到ng作用域作为cssClasses的值,因为现在我把这个问题搁置起来,因为它并没有停止我的代码,只是一个痛苦的问题a$$。谢谢大家的帮助
.config(function($stateProvider, $urlRouterProvider, $compileProvider) {
        $compileProvider.debugInfoEnabled(false);

    });
.config(function($stateProvider, $urlRouterProvider, $compileProvider) {
        $compileProvider.debugInfoEnabled(true);

    });
$compileprovider.debuginfoenabled(false)
jqLite.prototype.addClass = function(cssClasses) {
  var x, y, cssClass, el, splitClasses, existingClasses;
  if (cssClasses && cssClasses != 'ng-scope' && cssClasses != 'ng-isolate-scope') {
    //............