Javascript 无法访问指令';s控制器

Javascript 无法访问指令';s控制器,javascript,angularjs,angularjs-directive,angularjs-scope,Javascript,Angularjs,Angularjs Directive,Angularjs Scope,我有一个简单的应用程序,但由于某些原因,我无法访问指令控制器中的$scope值 app.js var myApp = angular.module('myApp',['ngAnimate']); myApp.controller('controller1',['$scope',function($scope) { $scope.helloText = 'text'; }]) myApp.directive('myPanel',function(){ return {

我有一个简单的应用程序,但由于某些原因,我无法访问指令控制器中的$scope值

app.js

var myApp = angular.module('myApp',['ngAnimate']);
myApp.controller('controller1',['$scope',function($scope) {
    $scope.helloText = 'text';
}])
myApp.directive('myPanel',function(){
    return {
        restrict : "E",
        scope : {
            someText : "="
        },
        templateUrl : 'someTemplate.html'
        controller : function($scope) {
            console.log($scope.someText);// this is undefined
        }
    };
});
controller.js

var myApp = angular.module('myApp',['ngAnimate']);
myApp.controller('controller1',['$scope',function($scope) {
    $scope.helloText = 'text';
}])
myApp.directive('myPanel',function(){
    return {
        restrict : "E",
        scope : {
            someText : "="
        },
        templateUrl : 'someTemplate.html'
        controller : function($scope) {
            console.log($scope.someText);// this is undefined
        }
    };
});
指令.js

var myApp = angular.module('myApp',['ngAnimate']);
myApp.controller('controller1',['$scope',function($scope) {
    $scope.helloText = 'text';
}])
myApp.directive('myPanel',function(){
    return {
        restrict : "E",
        scope : {
            someText : "="
        },
        templateUrl : 'someTemplate.html'
        controller : function($scope) {
            console.log($scope.someText);// this is undefined
        }
    };
});
someTemplate.html

<h1>This is the text {{someText}}</h1>
这是文本{{someText}
main.html

<div ng-controller="controller1">
    <my-panel someText="helloText"></my-Panel>
</div>

需要一些指针来了解我做错了什么?

你的外壳脱落了

<my-panel some-text="helloText"></my-Panel>

您可以在

直截了当

标准化

Angular规范化元素的标记和属性名称,以确定哪些元素与哪些指令匹配。我们通常通过其区分大小写的规范化名称(例如ngModel)引用指令。但是,由于HTML不区分大小写,我们在DOM中以小写形式引用指令,通常在DOM元素(例如ng模型)上使用破折号分隔的属性

规范化过程如下:

从元素/属性的前面剥离x和数据。
将:、-、或_-分隔的名称转换为camelCase。

您应该在html中使用规范化名称
一些文本