angularJS - 我的指令 link 没有被调用
angularJS - my directive link is not called
我正在 angular 应用程序中创建新指令。由于某种原因,我的指令 link 没有被调用。有人可以帮我吗?
我的指令:<data-grid data=slideView.pages ></data-grid>
我的代码:
"use strict";
( function() {
var dataGridMaker = function( ) {
return {
scope: true,
replace: true,
template:"<h1>Testing</h1>",
link: function( ) {
console.log(" Hi there!!");//not calling
}
}
}
angular.module( "gridDataApp.directives", [] )
.directive( "dataGrid", dataGridMaker );
} ( ));
您的指令将无法识别,因为 HTML5 已经有 datagrid
元素。尝试将其名称更改为另一个。
"use strict";
( function() {
var dataGridMaker = function( ) {
return {
scope: true,
replace: true,
template:"<h1>Testing</h1>",
link: function( ) {
console.log(" Hi there!!");//not calling
}
}
}
angular.module( "gridDataApp.directives", [] )
.directive( "sampleGrid", dataGridMaker );
} ( ));
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<div ng-app="gridDataApp.directives">
<div sample-grid></div>
</div>
我正在 angular 应用程序中创建新指令。由于某种原因,我的指令 link 没有被调用。有人可以帮我吗?
我的指令:<data-grid data=slideView.pages ></data-grid>
我的代码:
"use strict";
( function() {
var dataGridMaker = function( ) {
return {
scope: true,
replace: true,
template:"<h1>Testing</h1>",
link: function( ) {
console.log(" Hi there!!");//not calling
}
}
}
angular.module( "gridDataApp.directives", [] )
.directive( "dataGrid", dataGridMaker );
} ( ));
您的指令将无法识别,因为 HTML5 已经有 datagrid
元素。尝试将其名称更改为另一个。
"use strict";
( function() {
var dataGridMaker = function( ) {
return {
scope: true,
replace: true,
template:"<h1>Testing</h1>",
link: function( ) {
console.log(" Hi there!!");//not calling
}
}
}
angular.module( "gridDataApp.directives", [] )
.directive( "sampleGrid", dataGridMaker );
} ( ));
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<div ng-app="gridDataApp.directives">
<div sample-grid></div>
</div>