我正试图在指令中的'enter'事件之后做一些事情.加载模板时,事件未触发.
这是应用声明
angular
.module('MyApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch'
])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/home.html',
controller: 'HomeCtrl'
})
.when('/in-the-community', {
templateUrl: 'views/in-the-community.html',
controller: 'CommunityCtrl'
})
.otherwise({
redirectTo: '/'
});
});
Run Code Online (Sandbox Code Playgroud)
最初我使用路由提供程序给我一个模板页面.然后我尝试在这些模板中使用指令来提供另一个视图.这可以在我的模板页面中使用以下内容
<div class="flex">
<div class="fc fci image-wrapper" id="home-banner">
</div>
<div class="fc fcc">
<section show-and-hide-content="{{ sub_content }}">
</section>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这将在以下指令中加载
angular.module('rubisApp')
.directive('showAndHideContent', function ($animate) {
return {
templateUrl: 'views/community-sub.html',
controller: 'CommunitySubCtrl',
link: function(scope, element, attributes) {
$animate.on('enter', element,
function callback(element, phase) {
console.log('attributes.showAndHideContent');
}
); …Run Code Online (Sandbox Code Playgroud) 我有一个字符串列表,如下所示:
/disk1/home/alb/main/directory1/image0001.png
我想在最后一个之后删除所有内容并最终得到一个如下所示的字符串:
/disk1/home/alb/main/directory1/
有没有快速的方法来做到这一点?
谢谢