未添加AngularJS类ng-scope [英] AngularJS class ng-scope is not being added

查看:408
本文介绍了未添加AngularJS类ng-scope的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I"m following the Angular Tutorials and I see in their example that ng-scope is added to each element with a directive.

https://docs.angularjs.org/guide/scope

但是我自己的代码并没有为每个指令添加 ng-scope ,似乎所有事情都可以通过渲染数据来实现,但是出于某种原因,这个CSS类是没有添加.

But my own code does NOT add the ng-scope for each directive, every thing seems to work from rendering the data, but for some reason this CSS class is not added.

我的应用程序是从Yeoman.io入门项目开始的,所以我不确定该项目中是否有某些问题引起了问题.

My Application has started life from a Yeoman.io starter project so I'm not sure if something in that project has caused the issue.

https://github.com/diegonetto/generator-ionic

我已将www代码作为.zip添加到我的保管箱中:

Ive added the www code as a .zip in my dropbox:

https://www.dropbox.com/s/hn36080isu83vw5/www.zip

教程示例

我的例子

HTML

<h1 style="margin-top: 50px;">Scope Heirachy</h1>

<div class="show-scope-demo">
    <div ng-controller="ParentGreetController">
        Hello {{name}}!
    </div>
    <div ng-controller="ChildListController">
        <ol>
            <li ng-repeat="name in names">{{name}} from {{department}}</li>
        </ol>
    </div>
</div>

Controller.JS

Controller.JS

var moduleTest = angular.module('test', []);


moduleTest
    .controller('ParentGreetController', ['$scope', '$rootScope', function ($scope, $rootScope)
    {
        $scope.name = 'World';
        $rootScope.department = 'Angular';
    }])

    // We will access name which is in both scopes
    .controller('ChildListController', ['$scope', function ($scope)
    {
        $scope.names = ['Igor', 'Misko', 'Vojta'];
    }]);

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');
});

我尝试在&上设置debugInfoEnabled使用以下内容

I have tried setting debugInfoEnabled on & off using the following

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

    });

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

    });

推荐答案

检查是否在您的JavaScript中添加了以下代码行.这通常会删除调试信息,即Ng-scope.通常添加它是为了提高生产代码的性能.

Check if the following lines of code are added in your javascript. This usually removes debug info i.e. Ng-scope. This is usually added to improve performance in production code.

$compileprovider.debuginfoenabled(false)

这篇关于未添加AngularJS类ng-scope的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆